Advertisement
Guest User

Untitled

a guest
Jul 15th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.80 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4.  
  5. using namespace std;
  6.  
  7. int input(){
  8.   int a;
  9.   cin >> a;
  10.   if ((a>9 & a<100)|(a<(0-9)&a<(0-100))){
  11.     return a;
  12.   } else {
  13.     return input();
  14.   }
  15. }
  16.  
  17. int main() {
  18.   int a = input();
  19.   int b = a;
  20.   int sum = 0;
  21.   while (a != 0){
  22.     sum += a % 10;
  23.     a /= 10;
  24.   }
  25.  
  26.   cout << sum << endl;
  27.  
  28.   if ((sum>9 & sum<100)|(sum<(0-9)&sum<(0-100))){
  29.     cout << "Сумма чисел - двузначное число" << endl;
  30.   } else {
  31.     cout << "Сумма чисел - не двузначное число" << endl;
  32.   }
  33.   if (b % sum == 0){
  34.     cout << "Сумма чисел кратна числу а" << endl;
  35.   } else {
  36.     cout << "Сумма чисел не кратна числу а" << endl;
  37.   }
  38.   return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement