有错吗?简单问题,帮忙看看
这是它给出的错误
Your program ('ride') exited with signal #11 (segmentation violation [maybe caused by accessing memory out of bounds, array indexing out of bounds, using a bad pointer (failed open(), failed malloc), or going over the maximum specified memory limit]) when presented with test case 1, shown below:
--------------------------
COMETQ
HVNGAT
--------------------------
The program ran for 0 CPU seconds before the signal.
Please fix the error and resubmit.
我的代码在下面
#include <stdio.h>
/*
ID: loving_1
PROG: ride
*/
int main()
{
FILE* ifp;
FILE* ofp;
int i = 1;
int j = 1;
int c;
char GO[] = "GO";
char STAY[] = "STAY";
ifp = fopen("Input.txt","r");
ofp = fopen("Output.txt","w");
while((c=fgetc(ifp))!='\n')
i = ((c - 'A'+1) * i) % 47;
while((c=fgetc(ifp))!='\n' && c!=EOF)
j = ((c - 'A'+1) * j) % 47;
if(i != j)
fputs(GO, ofp);
else
fputs(STAY, ofp);
return 0;
}
它有这样的提示
NOTE: The input file has a newline at the end of each line but does not have a "return". Sometimes, programmers code for the Windows paradigm of "newline" followed by "return"; don't do that! Use simple input routines like "readln" (for Pascal) and, for C/C++, "fscanf" and "fid>>string".