|
|
back to boardHow To Use scanf To AC in G++ void Read() { int i,j;char In[NUM]; scanf("%d%d",&n,&m); for(i=0;i<=n+1;i++) for(j=0;j<=m+1;j++)Map[i][j]=1; for(i=1;i<=n;i++) { scanf("%s",In); for(j=1;j<=m;j++) { Map[i][j]=(In[j-1]=='*'); if(!Map[i][j]){tx=i;ty=j;} } } } this Read() got AC I think it's probably because the '\n' at the end of the line try this change: void Read() { int i,j;char ch; scanf("%d%d",&n,&m); for(i=0;i<=n+1;i++) for(j=0;j<=m+1;j++)Map[i][j]=1; for(i=1;i<=n;i++) { scanf("%c",&ch); for(j=1;j<=m;j++) { scanf("%c",&ch); Map[i][j]=(ch=='*'); if(!Map[i][j]){tx=i;ty=j;} } } } I tested and both can AC this problem. |
|
|