Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
大水题。#include <iostream> #include <cstring> #include <stdio.h> using namespace std; int main() { char shu[110][110]; int jg[150]; int gs = 0; while(1){ scanf("%s", shu[gs]); if(strcmp("0", shu[gs]) == 0) break; gs++; } int len[110]; for(int i = 0; i < gs; i++){ len[i] = strlen(shu[i]); } int carry = 0; for(int i = 0; i < 150; i++){ for(int j = 0; j < gs; j++){ if(len[j] > i){ carry += (shu[j][len[j]-i-1] - '0'); } } jg[i] = carry%10; carry /= 10; } bool zeroed = 1; for(int i = 149; i >= 0; i--){ if(!zeroed || jg[i]!=0){ zeroed=0; printf("%d",jg[i]); } } if(zeroed) printf("0"); printf("\n"); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator