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

Re:我代码在VC++上运行正常,但是提交后却说编译错误,但是错误却很可笑

Posted by qiqiboy at 2010-05-09 12:07:57 on Problem 1002 and last updated at 2010-05-09 22:29:42
In Reply To:我代码在VC++上运行正常,但是提交后却说编译错误,但是错误却很可笑 Posted by:qiqiboy at 2010-05-09 10:53:32
突然想到,main()中最后两个for循环可以不用,这样:
	for (int i=0;i<num;i++){
		if(*(a+i)>1&&*(phone_num+i)!=-1){
                x=1;
		printf("%03d-%04d %d\n",*(phone_num+i)/10000,*(phone_num+i)%10000,*(a+i));
		}
	}



替换以下两个for循环
	int z[7]={1000000,100000,10000,1000,100,10,1};
	for (int i=0;i<num;i++){
		if(*(a+i)>1&&*(phone_num+i)!=-1){
			int sum=*(phone_num+i);
			for(int j=0;j<7;j++){
				(*(final+i))[j]=sum/z[j]+'0';
				sum=*(phone_num+i)%z[j];
			}
		}
	}//*final存储转换过来的字符数字

	for (int i=0;i<num;i++){
		if(*(a+i)>1&&*(phone_num+i)!=-1){
			x=1;
			for(int j=7;j>3;j--)
				(*(final+i))[j]=(*(final+i))[j-1];	//第四位往后依次后移一位
			(*(final+i))[3]='-';					//在第四位存储'-'
			(*(final+i))[8]='\0';					//最后存储'\0',方便打印输出
			printf("%s %d\n",*(final+i),*(a+i));
		}
	}

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