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 lijingwei at 2010-07-04 11:58:36 on Problem 1519
#include <iostream>
using namespace std;
int main()
{
	int i,sum,b,n;
	char a[2000];
	while(1)
	{
		scanf("%s",a);
		if(strcmp(a,"0")==0)
			break;
		n=strlen(a);
		sum=0;
		for(i=0;i<n;i++)
		    sum+=a[i]-'0';		
	    b=sum%9;
	    if(b==0)
		b=9;	
	    cout<<b<<endl;
	}
	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