Advertisement
Guest User

01_Task1_Secret.cpp

a guest
Jul 15th, 2018
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. // 01_01_Task1_Secret.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <iostream> //for std::cout
  6. #include <string>
  7. #include <iomanip>    
  8. #include <cctype>      //char toupper, tolower  
  9.  
  10. using namespace std;
  11.  
  12. int main()
  13. {
  14.     cin.sync_with_stdio(false);
  15.     cout.sync_with_stdio(false);
  16.  
  17.     char ch;
  18.     cin >> ch;
  19.     int sum = 0;
  20.     while (ch != '.')
  21.     {
  22.         if (isdigit(ch))
  23.         {
  24.             sum += ch - 48;
  25.         }
  26.         cin >> ch;
  27.     }
  28.     if ((sum >= 65 && sum <= 90) ||
  29.         (sum >= 97 && sum <= 122))
  30.     {
  31.         cout << (char)sum << endl;
  32.     }
  33.     else
  34.     {
  35.         cout << sum << endl;
  36.     }
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement