SHARE
TWEET

Problema -6

Nita_Cristian Nov 19th, 2019 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /// Se da un text format din litere cifre si spatii sa se calculeze suma cifrelor din text
  2. #include<iostream>
  3. #include<cstring>
  4.  
  5. using namespace std;
  6.  
  7. char x[256];
  8.  
  9. int main()
  10. {
  11.     int s = 0;
  12.  
  13.     cin.getline(x,256);
  14.  
  15.     for(int i = 0; i < strlen(x); i++)
  16.     {
  17.         if(isalnum(x[i]) && !isalpha(x[i]))
  18.         {
  19.             s += x[i] - '0';
  20.         }
  21.     }
  22.     cout << s;
  23. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top