Advertisement
Dani_info

numar egal cu suma patratelor cifrelor sale

Oct 17th, 2017
98
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int n, c1, c2, c3, s;
  8. cout<<"Introduceti numarul de 3 cifre, n=";cin>>n;
  9. c1=n%10;
  10. c2=(n/10)%10;
  11. c3=n/100;
  12. s=c1*c1+c2*c2+c3*c3;
  13. if(n==s)
  14. cout<<"Numarul este egal cu suma patratelor cifrelor sale";
  15. else
  16. cout<<"Numarul nu este egal cu suma patratelor cifrelor sale";
  17.  
  18. return 0;
  19. }
Advertisement
RAW Paste Data Copied
Advertisement