【发布时间】:2011-02-13 13:39:30
【问题描述】:
大家好。我为在线比赛编写了这个程序。它在 Bloodshed 的 Dev-C++ 上运行良好,但在 GCC 上运行失败。本次大赛要求所有解决方案均基于GCC编译器。
它甚至不等待第二个输入。该程序在 Dev-C++ 上运行良好。请帮忙。
#include <stdio.h>
int testCases;
void runPgm()
{
scanf("%d", &testCases);
int array[testCases][2];
char start[testCases];
int i;
for(i=0; i<testCases; i++)
{
scanf("%c %d %d", &start[i], &array[i][0], &array[i][1]);
}
for(i=0; i<testCases; i++)
{
printf("%c %d %d\n", start[i], array[i][0], array[i][1]);
}
}
int main() {
runPgm();
return 0;
}
GCC 的输出:
machine:~$ cc prog.c -lm
machine:~$ ./a.out
2
a 3 3
0 -1080493616
a 3 3
machine:~$
【问题讨论】:
-
那么,您的程序是如何中断的?编译或运行时错误?
-
运行时.. 等我添加输出..
-
fflush(stdin);调用 UB BTW -
我刚刚添加了它..它甚至之前都不起作用..
-
改进了描述并提供了可编译的源代码,以便人们进行测试。