c++转换成c语言
#include <bits/stdc++.h>
using namespace std;
const int N = 1004;
int dis[N][N];
int n,m;
double d;
queue< pair<int,int> >q;
void bfs()
{
q.push(make_pair(1, 1));
while(!q.empty())
{
pair<int,int> t = q.front();
q.pop();
int x = t.first, y = t.second;
int tx = x, ty = y + (int)d;
if((n-x)*(n-x) + (m-y)*(m-y) <= d*d)
{
dis[n][m] = dis[x][y] + 1;
break;
}
while(tx <= n && ty >= y && ty <= m)
{
if((tx - x) * (tx - x) + (ty - y) * (ty - y) <= d * d && dis[tx][ty] == 0)
{
q.push(make_pair(tx, ty));
dis[tx][ty] = dis[x][y] + 1;
tx ++;
}
else ty --;
}
}
cout<<dis[n][m]<<endl;
}
int main()
{
cin>>n>>m>>d;
bfs();
return 0;
}
如上