C语言编程: 打印以下形式的数据
来源:百度知道 编辑:UC知道 时间:2024/06/08 04:37:28
1 3 6 2 9
3 6 2 9 1
6 2 9 1 3
2 9 1 3 6
9 1 3 6 2
3 6 2 9 1
6 2 9 1 3
2 9 1 3 6
9 1 3 6 2
#include <iostream>
using namespace std;
int main()
{
int a[5]={1,3,6,2,9};
int temp;
int k;
for(int i=0;i<5;i++)
{
for(int j=0;j<5;j++)
{
cout<<a[j]<<" ";
}
cout<<endl;
temp=a[0];
for(k=0;k<4;k++)
{
a[k]=a[k+1];
}
a[k]=temp;
}
}