Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

大水题。

Posted by KatrineYang at 2016-11-10 11:43:55 on Problem 1503
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator