[讨论] testgirl 54题 求助!

楼主: felixgwu (哈哈哈之王)   2010-11-27 22:25:53
testgirl 54题,题目在
http://palcourse.csie.ntu.edu.tw/testgirl/problem/c2007/practice/CharProcessing.htm
不知道为什么
第 5 次试验:你的程式当掉了!>"< 原因:使用到不该用的内存
没有通过试验。:(
实在找不出bug,请强者解惑
这是我的程式码
#include<stdio.h>
#include<string.h>
int main()
{
//FILE *fin=fopen("input.txt","r");
char CHA[40000],com[]="COMMAND";
char now;
int pos;
int i,j,k,l=0;
fscanf(stdin,"%*s");
fscanf(stdin,"%*c");
while(1)
{
fscanf(stdin,"%c",&CHA[l++]);
CHA[l]='\0';
if(l>=7)
if(strcmp(&CHA[l-7],com)==0)
{
CHA[l-7]='\0';
l-=7;
break;
}
}
while(fscanf(stdin,"%*s %d %c",&pos,&now)!=EOF)
{
for(i=l++;i>=pos;i
作者: math120908 (小小郭)   2009-01-27 22:56:00
是说...他没有规定insert指令一定要照顺序输出吧= =??而且这题不是要你用linked-list吗(茶)
楼主: felixgwu (哈哈哈之王)   2009-01-27 23:36:00
抱歉,想说要考string,先练习string的写法不照顺序输出,是什么意思呢?抱歉,我听不太懂
作者: math120908 (小小郭)   2009-01-27 23:39:00
哦就是说他可能先出现insert 10 X再出现insert 1 X吧!?咦我发现我皓呆掉了XDDD 没事Q_Q"好像是阵列太小的关系= ="
楼主: felixgwu (哈哈哈之王)   2009-01-28 00:02:00
谢谢,本来想说设40000就够的说

Links booklink

Contact Us: admin [ a t ] ucptt.com