1156:0 start-up algorithm 63--bow matrix time limit:1 Sec Memory limit:64 MB 64bit IO Format:%lld
submitted:3403 accepted:1284
[Submit] [Status] [Web Board] Description
Bow-type matrix for output n*m
Input multiple sets of test data
Enter 2 integers n and m per group (not greater than 20)
Output
The bow matrix of the output n*m requires that the upper-left element is 1, (each element occupies 2 positions, on the right)
Sample Input
4 3
Sample Output
1 2 3 6 5 4 7 8 912 11 10
Source
0 Starting point Learning algorithm
1#include <stdio.h>2#include <string.h>3 intMain () {4 intn,m,a[ -][ -];5 while(SCANF ("%d%d", &n,&m)! =EOF) {6 7Memset (A,0,sizeof(a));8 inttot,i,j;9Tot=a[i=0][j=0]=1;Ten while(tot<n*L) { One while(j+1<m) Aa[i][++j]=++tot; -a[++i][j]=++tot; - while(J-1>=0) thea[i][--j]=++tot; -a[++i][j]=++tot; - } - + for(intI=0; i<n;i++){ - for(intj=0; j<m-1; j + +){ +printf"%2d", A[i][j]); A } atprintf"%2d\n", a[i][m-1]); - } - } - - return 0; -}
Thought is very important!!!
1156:0 start-up algorithm 63--bow matrix