Advertisement
Dani_info

patartul sumei cifrelor=nr

Nov 26th, 2017
125
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 i, suma=0, p, uc, k, n;
  8.  
  9. cout<<"k="; cin>>k;
  10. for(i=1; i<=k; i++)
  11. {
  12. n=i;
  13. suma=0;
  14. while(n!=0)
  15. {
  16. uc=n%10;
  17. suma=suma+uc;
  18. n=n/10;
  19. }
  20. p=suma*suma;
  21. if(p==i)
  22. cout<<"Nr este:"<<i<<endl;
  23. }
  24. return 0;
  25. }
Advertisement
RAW Paste Data Copied
Advertisement