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

我用字符数组做的··代码绝不算多 yeah!

Posted by jacky5784 at 2011-08-02 17:37:57 on Problem 3077
#include<iostream>
using namespace std;
double tmp,input,ans;
int main()
{
	int n;
	char a[100];
	scanf("%d",&n);
	while(n--){

		scanf("%s",&a);

		for (int i=strlen(a) - 2;i>=0;--i)
			if (a[i+1] >= '5')
			{
				a[i+1] = '0';
				a[i] ++;
			}
			else
				a[i+1] = '0';
		if (a[0] > '9')
		{
			a[0] = '0';
			printf("1");
		}
		printf("%s\n",a);
	}
}

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