为什么ACM会报错,明明在VC上运行没问题,各位大神求救求教。
试编写一个程序完成:有两个磁盘文件“A”和“B”,各存放一行字母,今要求把这两个文件中的信息合并(按字母顺序排列),输出到一个新文件“C”中去。#include<stdi...
试编写一个程序完成:有两个磁盘文件“A”和“B”,各存放一行字母,今要求把这两个文件中的信息合并(按字母顺序排列),输出到一个新文件“C”中去。
#include <stdio.h>
#include <string.h>
main()
{
FILE *fpa,*fpb,*fpc;
char a[30],b[30],c[30],d[30],e[60],f[60];
int i,j,n;
gets(a);
gets(b);
if((fpa=fopen("C:\\A.txt","w")) != NULL)
fputs(a,fpa);
if((fpb=fopen("C:\\B.txt","w")) != NULL)
fputs(b,fpb);
fclose(fpa);
fclose(fpb);
if((fpa=fopen("C:\\A.txt","r")) != NULL)
{
fgets(c,30,fpa);
printf("the content of file A:%s\n",c);
}
if((fpb=fopen("C:\\B.txt","r")) != NULL)
{
fgets(d,30,fpb);
printf("the content of file B:%s\n",d);
}
strcpy(e,c);
strcat(e,d);
n=strlen(e);
for(i=0;i<n-1;i++)
{
for(j=i+1;j<n;j++)
{
char t;
if(e[i]>e[j])
{
t=e[i];
e[i]=e[j];
e[j]=t;
}
}
}
if((fpc=fopen("C:\\C.txt","w")) != NULL)
fputs(e,fpc);
fclose(fpc);
if((fpc=fopen("C:\\C.txt","r")) != NULL)
{
fgets(f,60,fpc);
printf("the content of file C:%s\n",f);
}
fclose(fpc);
} 展开
#include <stdio.h>
#include <string.h>
main()
{
FILE *fpa,*fpb,*fpc;
char a[30],b[30],c[30],d[30],e[60],f[60];
int i,j,n;
gets(a);
gets(b);
if((fpa=fopen("C:\\A.txt","w")) != NULL)
fputs(a,fpa);
if((fpb=fopen("C:\\B.txt","w")) != NULL)
fputs(b,fpb);
fclose(fpa);
fclose(fpb);
if((fpa=fopen("C:\\A.txt","r")) != NULL)
{
fgets(c,30,fpa);
printf("the content of file A:%s\n",c);
}
if((fpb=fopen("C:\\B.txt","r")) != NULL)
{
fgets(d,30,fpb);
printf("the content of file B:%s\n",d);
}
strcpy(e,c);
strcat(e,d);
n=strlen(e);
for(i=0;i<n-1;i++)
{
for(j=i+1;j<n;j++)
{
char t;
if(e[i]>e[j])
{
t=e[i];
e[i]=e[j];
e[j]=t;
}
}
}
if((fpc=fopen("C:\\C.txt","w")) != NULL)
fputs(e,fpc);
fclose(fpc);
if((fpc=fopen("C:\\C.txt","r")) != NULL)
{
fgets(f,60,fpc);
printf("the content of file C:%s\n",f);
}
fclose(fpc);
} 展开
1个回答
2015-06-06 · 知道合伙人互联网行家
关注
展开全部
让我们来看看北大POJ的官方解释:
Runtime Error (RE):The solution has caused an unhandled exception (as defined by the runtime environment) during execution.
Time Limit Exceeded(TLE):The solution has run for longer time than permitted. This means either the time spent on all test cases exceeds the overall limit or that spent on a single test case exceeds the per-case limit. Note that time limits for solutions in Java are tripled. These solutions are also allowed an extra 110 ms for each test case.
一般在本地没问题,上传即RE的,多是运行时数组申请不够大,一些大的测试数据使得超过了申请的空间所致。RE属于编译通过,运行时实时错误。而CE(Compile Error)属处怠边干装妨膘施博渐于编译错误。
参考资料:acm.pku.edu.cn/JudgeOnline/page?id=1000
Runtime Error (RE):The solution has caused an unhandled exception (as defined by the runtime environment) during execution.
Time Limit Exceeded(TLE):The solution has run for longer time than permitted. This means either the time spent on all test cases exceeds the overall limit or that spent on a single test case exceeds the per-case limit. Note that time limits for solutions in Java are tripled. These solutions are also allowed an extra 110 ms for each test case.
一般在本地没问题,上传即RE的,多是运行时数组申请不够大,一些大的测试数据使得超过了申请的空间所致。RE属于编译通过,运行时实时错误。而CE(Compile Error)属处怠边干装妨膘施博渐于编译错误。
参考资料:acm.pku.edu.cn/JudgeOnline/page?id=1000
追问
但我直接是wrong answer...
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询