Advertisement
Guest User

DUPA

a guest
Jan 27th, 2020
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. #include<iostream>
  2. #include<vector>
  3. using namespace std;
  4.  
  5.  
  6. int suma( int cyfra);
  7.  
  8. int main()
  9. {
  10.  
  11. int liczba_pocz,pomocnicza,n = 0;
  12.  
  13. cin>> liczba_pocz;
  14.  
  15.  
  16. vector <int> wszystkie;
  17. wszystkie.push_back(liczba_pocz);
  18. while (pomocnicza != 1)
  19. {
  20.  
  21. pomocnicza = suma(wszystkie[n]);
  22. cout<<pomocnicza;
  23. for( int i = 0 ; i < n ; i++)
  24. {
  25. if (pomocnicza == wszystkie [i])
  26. {
  27. cout<<liczba_pocz<< "nie jest wesola";
  28. return 0;
  29. }
  30. wszystkie.push_back(pomocnicza);
  31. n++;
  32. }
  33.  
  34. }
  35.  
  36. return 0;
  37. }
  38.  
  39. int suma( int cyfra)
  40. {
  41. int suma = 0;
  42. while ( cyfra != 0 );
  43. {
  44. suma += cyfra%10 * cyfra%10;
  45. cyfra/=10;
  46. }
  47. return suma;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement