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

Why always Runtime Error???请大牛们,大侠们不吝赐教!!

Posted by 2006011320 at 2007-02-23 17:15:24 on Problem 3077
#include<iostream>
#include<cmath>
#include<iostream>
using namespace std;
int main()
{
	int a,n,k,b,j,c,num[50000],i=1,u;
	cin>>n;
	
     while(n>0)
	 {
		 cin>>a;b=a;
         for(k=0;b>0;b/=10,k++);//计算是a几位数
		 b=a%(int)pow(10,k-1);c=5;
		 for(j=k-2;j>=1;j--)c+=4*pow(10,j);//是444..45
         if(b>=c)a+=pow(10,k-1);
         a/=pow(10,k-1);//只保留a的最高位
         a*=pow(10,k-1);num[i]=a;
		 n--;i++;
	}
	 for(u=1;u<i;u++)cout<<num[u]<<endl;
	return 1;
}

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