Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int sumaKwadratowCyfrLiczby(int l)
- {
- int suma = 0;
- while (l != 0)
- {
- suma += (l % 10)*(l % 10);
- l /= 10;
- }
- return suma;
- }
- bool czyWesola(int l)
- {
- if (sumaKwadratowCyfrLiczby(l) == 1)
- return true;
- else if (sumaKwadratowCyfrLiczby(l) == 4)
- return false;
- else
- return czyWesola(sumaKwadratowCyfrLiczby(l));
- }
- int main()
- {
- int xD;
- cin >> xD;
- if (xD == 0)
- return 0;
- if (czyWesola(xD))
- cout << 1;
- else cout << 4;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement