1155: 零起点学算法62——输出矩阵
生活随笔
收集整理的這篇文章主要介紹了
1155: 零起点学算法62——输出矩阵
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
1155: 零起點學算法62——輸出矩陣
Time Limit: 1 Sec??Memory Limit: 64 MB?? 64bit IO Format: %lldSubmitted: 997??Accepted: 557
[Submit][Status][Web Board]
Description
輸出n*m的矩陣
?
Input
多組測試數(shù)據(jù)
每組輸入2個整數(shù) n和m(不大于20)?
?
Output
輸出n*m的矩陣,要求左上角元素是1,然后從左到右 從上到下依次增大
?
Sample Input
3 4?
Sample Output
1 2 3 4 5 6 7 8 9 10 11 12?
Source
零起點學算法
?
1 #include<stdio.h> 2 int main(){ 3 int n,m,a[20][20]; 4 while(scanf("%d%d",&n,&m)!=EOF){ 5 int t=1; 6 for(int i=0;i<n;i++){ 7 for(int j=0;j<m;j++){ 8 a[i][j]=t; 9 t++; 10 } 11 } 12 13 for(int i=0;i<n;i++){ 14 for(int j=0;j<m-1;j++){ 15 printf("%d ",a[i][j]); 16 } 17 printf("%d\n",a[i][m-1]); 18 } 19 } 20 return 0; 21 }?
?
轉(zhuǎn)載于:https://www.cnblogs.com/dddddd/p/6684292.html
總結(jié)
以上是生活随笔為你收集整理的1155: 零起点学算法62——输出矩阵的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。