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 pktop at 2009-08-01 15:00:04 on Problem 1519
/* Note:Your choice is C IDE */
#include <iostream>
using namespace std;
int main()
{
  int a[1200],i,n,sum=0;
  char b[1200];
  while(1){
  	scanf("%s",b);
  	if(b[0]==48)
  	   break;
  	n=strlen(b);
  	for(i=0;i<n;i++){
  	   a[i]=b[i]-48;
  	   sum+=a[i];
  	   if(sum>=10)
  	     sum=sum-10+1;
  	}
  	printf("%d\n",sum);
  	sum=0;}
  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