本文最后更新于 1163 天前,其中的信息可能已经有所发展或是发生改变。
代码语言:javascript复制#include<iostream>
#include<cstring>
using namespace std;
int main(){
int arr[1000][100];
memset(arr,0,sizeof(arr));
cout<<"please input"<<endl;
int w,v,m,n,maxn,minn,x1,y1,x2,y2,tempx,sum=0;
cin>>w>>m>>n;
if(m>n){
maxn=m;
minn=n;
}else{
maxn=n;
minn=m;
}
for(int i=0;;i ){
int j;
if(i==0||i%2==0){
for(j=0;j<w;j ){
sum ;
arr[i][j]=sum;
if(sum==minn){
x1=i;
y1=j;
cout<<"sum:"<<sum<<"1minn:"<<minn<<":"<<x1<<" "<<y1<<endl;
}
if(sum==maxn){
x2=i;
y2=j;
cout<<"sum:"<<sum<<"2maxn:"<<maxn<<":"<<x2<<" "<<y2<<endl;
}
}
}else{
for(j=w-1;j>=0;j--){
sum ;
arr[i][j]=sum;
if(sum==minn){
x1=i;
y1=j;
cout<<"sum:"<<sum<<"3min:"<<x1<<" "<<y1<<endl;
}
if(sum==maxn){
x2=i;
y2=j;
cout<<"sum:"<<sum<<"4maxn:"<<x2<<" "<<y2<<endl;
}
}
}
if(sum>=maxn){
break;
}
}
int flag=1;
for(int i=0;;i ){
int j=0;
for(;j<w;j ){
cout<<arr[i][j]<<" ";
}
cout<<endl;
if(flag==0){
break;
}
if(arr[i][--j]==0){
flag=0;
}
}
tempx=x1-x2;
if(tempx<0){
tempx=-1*tempx;
}
cout<<tempx y2-y1;
return 0;
}
Post Views: 250