Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// Se da un text format din litere cifre si spatii sa se calculeze suma cifrelor din text
- #include<iostream>
- #include<cstring>
- using namespace std;
- char x[256];
- int main()
- {
- int s = 0;
- cin.getline(x,256);
- for(int i = 0; i < strlen(x); i++)
- {
- if(isalnum(x[i]) && !isalpha(x[i]))
- {
- s += x[i] - '0';
- }
- }
- cout << s;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement