矩阵输出
Time Limit: 1000MS Memory Limit: 65536KB
Problem Description
输入n个整数,输出由这些整数组成的n行矩阵。
Input
第一行输入一个正整数N(N<=20),表示后面要输入的整数个数。
下面依次输入N个整数。
Output
以输入的整数为基础,输出有规律的n行数据。
Example Input
5 3 6 2 5 8
Example Output
3 6 2 5 8 8 3 6 2 5 5 8 3 6 2 2 5 8 3 6 6 2 5 8 3
Hint
Author
参考代码
#include<stdio.h>
int main()
{
int a[20];
int n;
int i,j;
int temp;
scanf("%d",&n);
for(i = 0; i < n; i++)
scanf("%d",&a[i]);
for(i = 0; i < n; i++)
{
for(j = 0; j < n; j++)
{
if(j == n - 1)
printf("%d\n",a[j]);
else
printf("%d ",a[j]);
}
temp = a[n-1];
for(j = n - 1; j > 0; j--)
{
a[j] = a[j-1];
}
a[0] = temp;
}
return 0;
}
本文介绍了一个简单的编程问题:如何通过给定的整数序列构建一个特定形式的矩阵,并提供了实现这一功能的C语言代码示例。
2085

被折叠的 条评论
为什么被折叠?



