Advertisement
icatalin

Problema 4 tema suplimentara

Nov 27th, 2013
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. //Se cere sa se afiseze toate numerele de 3 cifre avand cifrele în ordine crescatoare si suma lor este egala cu 18.
  2.  
  3. #include <iostream>
  4.  
  5. using namespace std;
  6.  
  7. int main()//4.  Se cere să se afișeze toate numerele de 3 cifre având cifrele în ordine crescătoare și suma lor este egală cu 18.
  8. {
  9.     int n=999,a,b,c,s,cn;
  10.     for (n;n>=100;n=n-1)
  11.     {
  12.         cn=n;
  13.         c=cn%10;
  14.         cn=cn/10;
  15.         b=cn%10;
  16.         cn=cn/10;
  17.         a=cn%10;
  18.         s=a+b+c;
  19.  
  20.         if (a<b && b<c && s==18)
  21.             cout<<n<<endl;
  22.  
  23.  
  24.     }
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement