#include <stdio.h>
#define N 100
int main() {
int a[N][N]={0};
int i,j,k,x,y,z,n,m;
scanf("%d %d",&n,&m);
i=0;//입력행
j=0;//입력열
k=1;//입력값
x=1;
y=1;
z=n*m;
while(k<=z){
a[i++][j--]=k++;
if(i>=n || j<0){
if(x<m){
i=0;
j=x++;
}
else{
i=y++;
j=m-1;
}
}
}
for(i=0;i<n;i++){
for(j=0;j<m;j++){
printf("%d ",a[i][j]);
}
printf("\n");
}
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: