#include<iostream>
using namespace std;
int main(){
int Row,Col;
cin>>Row>>Col;
int* *Matrix=new int*[Row];
for(int i=0;i<Row;i++)
Matrix[i]=new int[Col];
for(int i=0;i<Row;i++)
for(int j=0;j<Col;j++)
Matrix[i][j]=-1;
//Process
int up=0,down=Row-1,left=0,right=Col-1;//±ß½ç
int r=0,c=0;
int count=1;
while(count<=Row*Col){//Ìî³ä
while(c<=right)
Matrix[r][c++]=count++;
c--;
up++;
r++;//ÉϺá
while(r<=down)
Matrix[r++][c]=count++;
r--;
right--;
c--;//ÓÒÊú
while(c>=left)
Matrix[r][c--]=count++;
c++;
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余1页未读,立即下载