Algorithm_ZRF @ 2024-02-01 14:19:59
inline void Read() {
cin >> n;
for(int i = 1; i <= n; ++i) {
for(int j = 1; j <= n; ++j) {
cin >> mp[i][j];
}
}
cin >> Start.x >> Start.y >> End.x >> End.y;
}
by Algorithm_ZRF @ 2024-02-01 14:24:30
附上变量定义:
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 ___nyLittleT___ @ 2024-02-01 14:33:39
中间没有空格,你需要通过字符串读入再转为整数。 @Algorithm_ZRF
by Algorithm_ZRF @ 2024-02-01 14:36:01
@nyLittleT ?
by Algorithm_ZRF @ 2024-02-01 14:47:18
@nyLittleT char数组可以吗
by ___nyLittleT___ @ 2024-02-01 14:48:08
@Algorithm_ZRF 可以的
by Algorithm_ZRF @ 2024-02-01 14:50:25
@nyLittleT 谢谢
by ___nyLittleT___ @ 2024-02-01 14:50:28
@Algorithm_ZRF
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 Tsuri @ 2024-03-02 10:55:02
可以直接输入整数 scanf("%1d",&g[i][j]); 就可以了,每次只读一个
by Tiks_code @ 2024-03-17 10:51:47
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:52:41
@Tiks_code temp/=10下面再写一个x/=10