#11195: 一直TLE...


linjerry (xxxxxxxxxxxxx)


#include<stdio.h>
using namespace std;
int main()
{
int i,j,y,x;
int a[100][100];
while(scanf("%d %d", &i, &j))
{
for(y=0;y<i;y++)
{
for(x=0;x<j;x++)
scanf("%d", &a[y][x]);
}
for(x=0;x<j;x++)
{
for(y=0;y<i;y++)
printf("%d ", a[y][x]);
printf("\n");
}
}
return 0;
}

看別人解答跟我寫的一樣但是一直TLE!!!

為何會這樣?

#11201: Re:一直TLE...


Benson86 (nobodyzxc)


我會寫成while( ~ scanf("%d %d" , &i , &j)) 

因為scanf沒吃到東西(EOF)回傳 -1 不是零喔!