35657

Untitled

Oct 21st, 2023
815
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3.  
  4. using namespace std;
  5.  
  6.  
  7. int main() {
  8.     setlocale(LC_ALL, "ru");
  9.    
  10.     int x;
  11.     cout << "Введите число от 1 до 100: ";
  12.     cin >> x;
  13.  
  14.     if (x < 1 || x >= 100) {
  15.         cout << "Некорректный ввод" << endl;
  16.     }
  17.     else {
  18.         if (x >= 10 && x < 100) {
  19.             int result = x / 10 + x % 10;
  20.             cout << "Количество цифр - 2" << endl;
  21.             cout << "Сумма цифр - " << result << endl;
  22.         }
  23.         else {
  24.             cout << "Количество цифр - 1" << endl;
  25.             cout << "Сумма цифр - " << x << endl;
  26.         }
  27.     }
  28.    
  29. }
  30.  
  31.  
Advertisement
Add Comment
Please, Sign In to add comment