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 wuqianhu12 at 2006-12-07 13:35:33 on Problem 1519
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main ()
{
    long N,sum=0,i;
    char str[100];
	memset(str,'0',100);

	while(1)
	{

	scanf("%d",&N);

    while(N>0)
	{
	  sprintf(str,"%99d",N);

	  for(i=0;i<strlen(str);i++)
	  {
		  if(str[i]==' ')
		   sum=0;
		  else
	       sum+=str[i]-'0'; 
	  }
	
	  N=sum;
	  if(N<=9&&N>=0)
	  {
		 printf("%d",N);
	     break;
	  }
	}
	printf("\n");
	}

}

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