Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.13 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int x,n,c=0,r,s=0,og=0,s2=0,s3=0;
  8.     cin>>x;
  9.     n=x;
  10.     cout<<"a) ultima cifra: "<<x%10<<endl;
  11.     cout<<"b) penultima cifra: "<<(x/10)%10<<endl;
  12.     if(((x/100)%10)%2==0) cout<<"c) Antepenultima cifra ("<<(x/100)%10<<") e para: "<<endl;
  13.         else cout<<"c) Antepenultima cifra ("<<(x/100)%10<<") e impara: "<<endl;
  14.     while(n>0)
  15.     {
  16.         r=n%10; //ultima cifra
  17.         c++; //contor cifre
  18.         if(r%2==0) s2=s2+r; //suma cifre pare
  19.         if(r%3==0) s3=s3+r; //suma cifre div cu 3
  20.         s=s+r; //suma cifre
  21.         og=og*10+r; //oglindit
  22.         n=n/10; //decrementare pe cifra
  23.     }
  24.         cout<<"d) prima cifra: "<<r<<endl;
  25.         cout<<"e) cate cifre are nr: "<<c<<endl;
  26.         cout<<"f) suma cifre pare: "<<s2<<endl;
  27.         cout<<"g) suma cifrelor: "<<s<<endl;
  28.         cout<<"h) suma cifre div cu 3: "<<s3<<endl;
  29.         if(x%10!=2) cout<<"i) prima cifra impara de la D la S: "<<x%10<<endl;
  30.             else cout<<"i) prima cifra impara de la D la S: "<<(x-x%10)/10%10<<endl;
  31.         cout<<"l) oglindit: "<<og<<endl;
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement