1 solutions
-
0
C :
#include<stdio.h> #include<stdlib.h> int main() { int j; int n; scanf("%d", &n); int *a = (int *)malloc(n*sizeof(int)); int *b = (int *)malloc(n*sizeof(int)); int *ans = (int *)malloc(n*sizeof(int)); for(j = 0; j < n; j++) { scanf("%d%d", &a[j], &b[j]); ans[j] = 0; } for(j = 0; j < n; j++) { int c = 0; for(int i = 9; i >= 0; i--) { c = (a[j]%10 + b[j]%10 + c) > 9 ? 1 : 0; ans[j] += c; a[j] /= 10; b[j] /= 10; } } for(j = 0; j < n; j++) { printf("%d\n", ans[j]); } free(a); free(b); free(ans); return 0; }
- 1
Information
- ID
- 503
- Time
- 1000ms
- Memory
- 2MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By