C++:用循环语句编程打印如下矩阵:
1 0 1 2 3 4 5 6
2 1 2 3 4 5 6 0
3 2 3 4 5 6 0 1
4 3 4 5 6 0 1 2
5 4 5 6 0 1 2 3
6 5 6 0 1 2 3 4
#include <iostream>
using namespace std;
int main()
{
int a[8] = {1, 0, 1, 2, 3, 4, 5, 6};
for (int i = 0; i < 6; i++)
{
for (int j = 0; j < 8; j++)
{
cout << a[j] << " ";
a[j] = (a[j] + 1) % 7;
}
cout << endl;
}
return 0;
}