1 to 9 numbers are added to each row after the number is equal to the nine Gongge algorithm of 15

Source: Internet
Author: User

1 /// <summary>2         ///Nine Gongge algorithm3         /// </summary>4          Public voidninetable ()5         {6             //Create a third-order phalanx7             int[,] arr =New int[3,3];8             //row subscript for line 3rd9             intA =2;Ten             //row subscript for line 2nd One             intb =3/2; A             //Assigning a value to an array -              for(inti =1; I <=9; i++) -             { thearr[a++, b++] =i; -  -                 //If I is a multiple of 3 -                 ifI3==0) +                 { -A = A-2; +B = B-1; A                 } at                 Else //If I is not a multiple of 3 -                 { -A = a%3; -b = b%3; -                 } -             } in  -StringBuilder SB =NewStringBuilder (); to             //traversing output nine lattice +              for(inti =0; I <3; i++) -             { the                  for(intj =0; J <3; J + +) *                 { $Sb. Append (Arr[i, J]. ToString () +" ");Panax Notoginseng                 } -Sb. Append ("<br/>"); the             } +Lbninetable.text ="output nine lattice:<br/>"+sb. ToString (). Trim (); A}
View Code

The results of the program run are as follows:

Output Nine Gongge:
4 9 2
3 5 7
8 1 6

1 to 9 numbers are added to each row after the number is equal to the nine Gongge algorithm of 15

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.