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

我疯了……char x[100]再加上3个整型为什么内存超标?????!!!!!!!

Posted by oldboy at 2004-03-13 14:38:58 on Problem 1519
#include<iostream.h>
#include<string.h>

void main()
{
	char num[100];
	int i,sum,a;

	while(strcmp(num,"0")!=0){
		cin>>num;
		if (strcmp(num,"0")==0)
			break;
		if (strlen(num)==1){
			cout<<num<<endl;
			continue;
		}
		sum=0;
		for (i=0;i<int(strlen(num));i++)
			sum+=num[i]-'0';
		a=100;
		while(a>=10){
			a=0;
			while(sum!=0){
				a+=sum%10;
				sum=sum/10;
			}
			sum=a;
		}
		cout<<a<<endl;
	}
}

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