1156:0 start-up algorithm 63--bow matrix

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.