Compiler problem?
Posted: Fri May 21, 2004 9:53 pm
Hi,
I'd like to know why at the code that begins like this:
# include <stdio.h>
# define TMAX 62600
unsigned short int k,m,n,i,p,q,j,l;
char *txt="Case ";
unsigned short int sko1[TMAX], sko2[TMAX], sko3[TMAX], sko4[TMAX];
int main() {
scanf("%d",&m);
for (i=1;i<=m;i++){
scanf("%d%d%d",&n,&p,&q);
for (j=0;j<=p;j++)
scanf("%d",&sko1[j]);
. . .
I got WA and execution tikme over 7s. But when I changed just the variable declaration part to the following:
# include <stdio.h>
# define TMAX 62600
unsigned short int i,k,m;
unsigned short int n,j,p;
unsigned short int q,l;
char *txt="Case ";
unsigned short int sko1[TMAX], sko2[TMAX], sko3[TMAX];
unsigned short int sko4[TMAX];
int main() {
scanf("%d",&m);
for (i=1;i<=m;i++){
scanf("%d%d%d",&n,&p,&q);
for (j=0;j<=p;j++)
scanf("%d",&sko1[j]);
. . .
I got AC and execution time less than 1s?? During debugging I recognized that the WA was linked to the strange behaviour of variable "i" which in the first version of programm surprisingly changed to 0 within the for loop after execution of scanf function.
Coudl somebody explain it??
I'd like to know why at the code that begins like this:
# include <stdio.h>
# define TMAX 62600
unsigned short int k,m,n,i,p,q,j,l;
char *txt="Case ";
unsigned short int sko1[TMAX], sko2[TMAX], sko3[TMAX], sko4[TMAX];
int main() {
scanf("%d",&m);
for (i=1;i<=m;i++){
scanf("%d%d%d",&n,&p,&q);
for (j=0;j<=p;j++)
scanf("%d",&sko1[j]);
. . .
I got WA and execution tikme over 7s. But when I changed just the variable declaration part to the following:
# include <stdio.h>
# define TMAX 62600
unsigned short int i,k,m;
unsigned short int n,j,p;
unsigned short int q,l;
char *txt="Case ";
unsigned short int sko1[TMAX], sko2[TMAX], sko3[TMAX];
unsigned short int sko4[TMAX];
int main() {
scanf("%d",&m);
for (i=1;i<=m;i++){
scanf("%d%d%d",&n,&p,&q);
for (j=0;j<=p;j++)
scanf("%d",&sko1[j]);
. . .
I got AC and execution time less than 1s?? During debugging I recognized that the WA was linked to the strange behaviour of variable "i" which in the first version of programm surprisingly changed to 0 within the for loop after execution of scanf function.
Coudl somebody explain it??
