题解 | #合并表记录#
合并表记录
http://www.nowcoder.com/practice/de044e89123f4a7482bd2b214a685201
include <stdio.h>
include <string.h>
int main(void)
{
long a[10000] = {0};
long i = 0; long j,k; long num = 0; scanf("%ld", &num); getchar(); char str[100]; long c; long d; char spit = ' '; for(i = 0;i < num;i++) { fgets(str,sizeof(str), stdin); // getchar(); sscanf(str, "%ld %ld %c", &c, &d, &spit); // printf("%ld, %ld\n",c,d); bzero(str,0); a[c] += d; } for(i = 0;i < 10000;i++) { if(a[i] == 0) continue; printf("%ld %ld\n", i,a[i]); } return 0;
}