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

为什么我的while循环没用,要泪崩了!!!1

Posted by 08063102 at 2011-07-25 10:57:34 on Problem 3077
#include<stdio.h>
#include<string.h>
int main()
{
	int n,m,j,k;
	char a[10];
	scanf("%d",&n);
	while(n--)
	{
	 scanf("%s",&a);
	m=strlen(a);
	if(m==1)
	{	
	printf("%s\n",a);
	continue;
	}
	else
	{
		
	for(k=m-1;k>=0;k--)
	{
	if(a[k]>='5')
     a[k-1]++;
	}
	if(a[0]>'9')
	{	
	a[0]='0';
    printf("1");
	}
	for(j=1;j<m;j++)
	{	 
	a[j]='0';
	}
	printf("%s\n",a);
   }
  } 
  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