Advertisement
999ms

Untitled

Oct 15th, 2020
2,592
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.25 KB | None | 0 0
  1. // chislovoi_koren_chisla.cpp : Этот файл содержит функцию "main". Здесь начинается и заканчивается выполнение программы.
  2. //
  3.  
  4. #include <iostream>
  5. #include <string>
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10.     string chislo;
  11.     char q;                                         //Переменная для остатков деление на 10
  12.     do {
  13.         cout << "Enter your nonnegative chislo " << endl;
  14.         cin >> chislo;                                                  //Ввод числа
  15.         bool bad = false;
  16.         for (char ch : chislo) {
  17.             if (ch < '0' || ch > '9') {
  18.                 bad = true;
  19.                 break;
  20.             }
  21.         }
  22.         if (bad) {
  23.             cout << "SUKA BLYADSKAYA VVODI NORM CHISLO GAY" << endl;
  24.             q = 'y';
  25.             continue;
  26.         }
  27.         long long sum = 0;
  28.         for (char ch : chislo) {
  29.             sum += ch - '0';
  30.         }
  31.         while (sum > 9) {                                           //Если в числе больше одной цифры, входим в цикл
  32.             long long ans = 0;
  33.             while (sum > 0) {                                       //Суммируем все цифры числа
  34.                 ans += sum % 10;
  35.                 sum /= 10;
  36.             }
  37.             sum = ans;
  38.         }
  39.  
  40.         cout << "Chislovoi koren is masafuck up " << sum << endl;
  41.         cout << "Do you want to continue, gay nigger?" << endl;
  42.         cin >> q;
  43.     } while ((q == 'y') or (q == 'Y'));
  44.     return 0;
  45.  
  46. }
  47.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement