高中生程式解題

a015: 矩陣的翻轉

 

範例輸入 : 
2 3
3 1 2
8 5 4

 

範例輸出 :

 

3 8
1 5
2 4

 

 

#include<stdio.h>

int main(void)
{
	int i,j,row,column;
	while(scanf("%d %d",&row,&column)!=EOF)
	{
		int num[row][column];
		for(i=0;i<row;i++)
		{
			for(j=0;j<column;j++)
				scanf("%d",&num[i][j]);
		}
		for(i=0;i<column;i++)
		{
			for(j=0;j<row;j++)
				printf("%d ",num[j][i]);
			printf("\n");
		}
	}
	return 0;
}

 

arrow
arrow
    全站熱搜

    東勢厝滴yang 發表在 痞客邦 留言(0) 人氣()