输入有问题!帮忙看一下(悬赏关注)

P1746 离开中山路

附上变量定义: ```cpp int dx[] = {1,-1,0,0}, dy[] = {0,0,1,-1}; struct co { int x,y; }; struct ss { int x,y,dis; }; int n; co Start,End; int mp[maxn][maxn]; ```
by Algorithm_ZRF @ 2024-02-01 14:24:30


中间没有空格,你需要通过字符串读入再转为整数。 @[Algorithm_ZRF](/user/1044048)
by ___nyLittleT___ @ 2024-02-01 14:33:39


@[nyLittleT](/user/1030733) ?
by Algorithm_ZRF @ 2024-02-01 14:36:01


@[nyLittleT](/user/1030733) char数组可以吗
by Algorithm_ZRF @ 2024-02-01 14:47:18


@[Algorithm_ZRF](/user/1044048) 可以的
by ___nyLittleT___ @ 2024-02-01 14:48:08


@[nyLittleT](/user/1030733) 谢谢
by Algorithm_ZRF @ 2024-02-01 14:50:25


@[Algorithm_ZRF](/user/1044048) ```cpp char s[N]; for(int i=1;i<=n;i++){ scanf("%s",s+1);//下标从1开始好处理一些 for(int j=1;j<=n;j++) mp[i][j]=s[j]-'0';//转为整数 } ```
by ___nyLittleT___ @ 2024-02-01 14:50:28


可以直接输入整数 scanf("%1d",&g[i][j]); 就可以了,每次只读一个
by Tsuri @ 2024-03-02 10:55:02


```cpp int main() { cin >> n; for (int i = 1; i <= n; i++) { int x; cin >> x; sub(x,i); } cin >> st.first >> st.second >> ed.first >> ed.second; cout << bfs(st.first, st.second, 0) << endl; } void sub(int x,int i) { while (x) { for (int j = 1; j <= n; j++) { string str = to_string(x); str.reserve(); int temp = stoi(str); a[i][j] = temp % 10; temp /= 10; ```
by Tiks_code @ 2024-03-17 10:51:47


@[Tiks_code](/user/1308662) temp/=10下面再写一个x/=10
by Tiks_code @ 2024-03-17 10:52:41


|