5、建立一个具有以下内容的方阵存入二维数组中。

来源:百度知道 编辑:UC知道 时间:2024/06/28 17:49:31
5、建立一个具有以下内容的方阵存入二维数组中。
1 2 3 4 5 6
2 3 4 5 6 1
3 4 5 6 1 2
4 5 6 1 2 3
5 6 1 2 3 4
6 1 2 3 4 5

#include<stdio.h>
main() {
int i,j;
int a[6][6];
for(i=0;i<6;i++){
for(j=i;j<6;j++) {
a[i][j]=j+1;
printf("%d",a[i][j]);
}
for(j=0;j<i;j++){
a[i][j]=j+1;
printf("%d",a[i][j]);
}
printf("\n");
}
}

#include<iostream>
using namespace std;

int main()
{
int a[6][6],
i,j;
for(i=0;i<5;i++)
{
if(i==0)
for(j=0;j<6;j++)
a[i][j]=j+1;

for(j=0;j<5;j++)
a[i+1][j]=a[i][j+1];
a[i+1][j]=a[i][0];
}

for(i=0;i<6;i++)
{
for(j=0;j<6;j++)
cout<<a[i][j]<<' ';
cout<<endl;
}

return 0;
}

#include<stdio.h>
void main()
{
int a[6][6],i,j,k;
for(k=0;k<=10;k++)
for(i=0;i<6;i++)
for(j=0;j<6;j++)