Serpentine array and "it" glyph print

Source: Internet
Author: User

Serpentine array: 650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/7F/52/wKioL1cZ7Bmz9Im7AABkMZGZTSQ588.png "title=" Untitled 3.png "alt=" Wkiol1cz7bmz9im7aabkmzgztsq588.png "/>

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>

the above array is called the Serpentine array .

How to print a serpentine array: Be sure not to consider a row, or you will fall into the wrong.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/7F/52/wKioL1cZ61rA1sUIAAB0kdx7aiU472.png "title=" Untitled. png "alt=" Wkiol1cz61ra1suiaab0kdx7aiu472.png "/>

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>

#include <stdio.h> #include <stdlib.h> #define &NBSP;LINE&NBSP;10&NBSP;VOID&NBSP;INITSARR (int arr[ Line][line]) {int i1 = 0;int j1 = 0;int m1 = line - 1; Int n1 = line - 1;int k = 0;int i2;int j2;int m2;int  n2;while  (I1&NBSP;&LT;=&NBSP;M1&AMP;&AMP;J1&NBSP;&LT;=&NBSP;N1) {for  (j2 = j1;  j2 <= n1; j2++)               //Print Line {k++;arr[i1][j2] = k from the first line;} for  (i2 = i1 + 1; i2 <= m1; i2++)               //Print column {k++;arr[i2][n1] = k from the last column;} for  (n2 = n1 - 1; n2 >= j1; n2--)              //print line {k++;arr[m1][n2] = k} from the last line; for  (m2 = m1 - 1; m2>i1; m2--)                  //Print column {k++;arr[m2][j1] = k from the first column;} j1++;                                      //prepare the next lap of print i1++;n1--;m1--;}} Void output (Int arr[line][line]) {int i;int j;for  (i = 0; i<line;  i++) {for  (j = 0; j<line; j++) {printf ("%5d",  arr[i][j]);} printf ("\ n");}} Int main () {Int arr[line][line];initsarr (arr); output (arr); system ("pause"); return 0;}



"It" Glyph print:

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/7F/54/wKiom1cZ63bgrsxyAABggVqvIRQ667.png "title=" Untitled 4.png "alt=" Wkiom1cz63bgrsxyaabggvqvirq667.png "/>

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>

Above this picture is "the" glyph prints out.


How to print a glyph of "it":

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/7F/54/wKiom1cZ6zny6Ox1AABrUrSEZHk114.png "title=" Untitled 1.png "alt=" Wkiom1cz6zny6ox1aabrursezhk114.png "/>

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>


#include <stdio.h> #include <stdlib.h> #define &NBSP;LINE&NBSP;10&NBSP;VOID&NBSP;OUTPUT (int arr[ Line][line]) {int i;int j;for  (i = 0; i<line; i++) {for  (j =  0; j<line; j++) {printf ("%5d",  arr[i][j]);} printf ("\ n");}} Void initsarr (Int arr[line][line]) {int i = 0;int j = 0;int k  = 0;int i2;int j2;for  (i = 0, j = 0; i<line& &j<line; i++, j++) {if  (i % 2 == 0)                        // The upper triangle Prints {for  (i2 = i, j2 = 0; i2 >= 0 &&) from lower left to upper right slash  j2 <= j; i2--,  j2++) {k++;arr[i2][j2] = k;}} Else                           //on the upper right-to-left diagonal of the print {for  (J2  = j, i2 = 0; j2 >= 0 && i2 <= i;  j2--,  i2++) {k++;arr[i2][j2] = k;}}} for  (i = line - 1, j = line - 1; i >= 0  && j >= 0; i--,  j--) {if  (i % 2 != 0)               {                                      //the lower triangle from the lower left to the upper right slash of the print for  (i2 =  line - 1, j2 = line - j; i2<line&&j2<line;  I2--,  j2++) {k++;arr[i2][j2] = k;}} else                 {                                      //the lower triangle from top right to the lower left slash of the print for  (i2 =  line - 1, j2 = line - j; i2<line&&j2<line;  I2--,  j2++) {k++;arr[j2][i2] = k;}}} Int main () {int arr[line][line];intput (arr); output (arr); system ("pause"); return 0;}


This article is from the "11132019" blog, please be sure to keep this source http://11142019.blog.51cto.com/11132019/1766796

Serpentine array and "it" glyph print

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.