Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<vector>
- using namespace std;
- int suma( int cyfra);
- int main()
- {
- int liczba_pocz,pomocnicza,n = 0;
- cin>> liczba_pocz;
- vector <int> wszystkie;
- wszystkie.push_back(liczba_pocz);
- while (pomocnicza != 1)
- {
- pomocnicza = suma(wszystkie[n]);
- cout<<pomocnicza;
- for( int i = 0 ; i < n ; i++)
- {
- if (pomocnicza == wszystkie [i])
- {
- cout<<liczba_pocz<< "nie jest wesola";
- return 0;
- }
- wszystkie.push_back(pomocnicza);
- n++;
- }
- }
- return 0;
- }
- int suma( int cyfra)
- {
- int suma = 0;
- while ( cyfra != 0 );
- {
- suma += cyfra%10 * cyfra%10;
- cyfra/=10;
- }
- return suma;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement