Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- #include <stdio.h>
- #include <ctype.h>
- #include <stdlib.h>
- using namespace std;
- int main()
- {
- char s[256][256];
- int n, sum = 0, k = 0;
- cin >> n;
- for (int i = 0; i < n; i++)
- cin >> s[i];
- for (int i = 0; i < n; i++)
- {
- int ok = 1, neg = 0;
- if (s[i][0] == '-')
- {
- neg = 1;
- strcpy(s[i], s[i] + 1);
- }
- for (int j = 0; s[i][j] && ok; j++)
- if (!isdigit(s[i][j]))
- ok = 0;
- if (ok)
- {
- int nr = atoi(s[i]);
- if (neg)
- nr = -nr;
- sum += nr;
- }
- else
- k++;
- }
- cout << k << ' ' << sum;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement