矩阵输出 (sdut oj)

来源:互联网 发布:mac怎么上传淘宝助理 编辑:程序博客网 时间:2024/06/05 01:08


矩阵输出

Time Limit: 1000MS Memory Limit: 65536KB



Problem Description

输入n个整数,输出由这些整数组成的n行矩阵。


Input

第一行输入一个正整数N(N<=20),表示后面要输入的整数个数。 
下面依次输入N个整数。


Output

以输入的整数为基础,输出有规律的n行数据。


Example Input

53 6 2 5 8


Example Output

3 6 2 5 88 3 6 2 55 8 3 6 22 5 8 3 66 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;}


0 0
原创粉丝点击