Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- #include <string.h>
- #include <stdbool.h>
- /**
- The sum of all numbers that are not 1 :
- Entrée
- 4
- 3
- 1 7 1
- 1 1 7
- 7 7 7
- Sortie
- 35
- */
- int main()
- {
- int c;
- scanf("%d", &c);
- int n;
- scanf("%d", &n); fgetc(stdin);
- int sum = 0;
- for (int i = 0; i < n; i++) {
- char row[257];
- scanf("%[^\n]", row); fgetc(stdin);
- for (int j = 0; j < strlen(row); j++) {
- if (row[j] != '1' && row[j] != ' ') sum += (row[j] - '0');
- }
- }
- printf("%d\n", sum);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement