C # Foundation Day two-job answer-99 multiplication table-print stars

Source: Internet
Author: User

question 1:99 The answer to the multiplication table//Positive Triangle             for(inti =1; I <Ten; i++)            {                 for(intj =1; J <= I; J + +) {Console.Write ("{0}*{1}={2}", J, I, I *j);            } Console.WriteLine ();            } console.readline (); //Inverted Triangle             for(inti =9; I >=1; i--)            {                 for(intj = i; J >=1; j--) {Console.Write ("{0}*{1}={2}", I, J, I * j);//No Line break} Console.WriteLine (); //line Break} console.readline (); Instead of the trianglestringSD =string.            Empty;  for(inti =9; I >=1; i--)            {                 for(intj = i; J >=1; j--)                {                    stringK ="  "; if(J * i >9) {k=" "; } console.write ("{0}*{1}={2}{3}", J, I, I *J, K);                } Console.WriteLine (); SD+="       ";            Console.Write (SD); } console.readline (); question two://Star Figure 1Console.WriteLine ("Please enter the number of star rows you want to see"); intnum =Convert.ToInt32 (Console.ReadLine ());  for(intHang =1; Hang <= num; hang++)            {                stringK =String.Empty; stringx =String.Empty;  for(intKong =1; Kong <= Num-hang; kong++) {k+=" "; }                 for(intXing =1; Xing <= hang; xing++) {x+="* "; } Console.WriteLine (k+ x +k);            } console.readline (); //Star Chart (inverted triangle star)Console.WriteLine ("Please enter the number of star rows you want to see"); intnum =Convert.ToInt32 (Console.ReadLine ());  for(intHang =1; Hang <= num; hang++)            {                stringK =String.Empty; stringx =String.Empty;  for(intKong =1; Kong <= Hang-1; kong++) {k+=" "; }                 for(intXing =1; Xing <= Num-hang +1; xing++) {x+="* "; } Console.WriteLine (k+ x +k);            } console.readline (); ////Star Figure fourConsole.WriteLine ("Please enter the number of star rows you want to see"); intnum =Convert.ToInt32 (Console.ReadLine ()); intGG = num *2;  for(intHang =1; Hang <= num; hang++)            {                stringK =String.Empty; stringx =String.Empty;  for(intKong =1; Kong <= GG-2* Hang; kong++) {k+=" "; }                 for(intXing =1; Xing <= hang; xing++) {x+="* "; } Console.WriteLine (k+x);            } console.readline (); //Star Chart (inverted triangle *)Console.WriteLine ("Please enter the number of star rows you want to see"); intnum =Convert.ToInt32 (Console.ReadLine ()); intGG = num *2;  for(intHang =1; Hang <= num; hang++)            {                stringK =String.Empty; stringx =String.Empty;  for(intKong =1; Kong <=2* (Hang-1); kong++) {k+=" "; }                 for(intXing =1; Xing <= Num-hang +1; xing++) {x+="* "; } Console.WriteLine (k+x);           } console.readline (); //Star Chart (final effect diamond)            intA =int.            Parse (Console.ReadLine ());  for(inti =0; I <= A; i++)            {                stringK =String.Empty; stringx =String.Empty;  for(ints =0; s < A-i +1; s++) {k+=" "; }                 for(intD =0; D <2I1; d++) {x+="*"; } Console.WriteLine (k+ x +k); }             for(inti = A-1; i >0; i--)            {                stringK =String.Empty; stringx =String.Empty;  for(ints =0; s < A-i +1; s++) {k+=" "; }                 for(intD =0; D <2I1; d++) {x+="*"; } Console.WriteLine (k+ x +k);          } console.readline (); //Star Chart (show figure four effects/Figure five effects) final display Figure six effect           for(inti =1; I <=4; i++)            {                 for(intj =1; J <=4I J + +) {Console.Write (" "); }                 for(intK =1; K <= i; k++) {Console.Write ("*"); } Console.WriteLine (""); }             for(inti =4; I >=1; i--)            {                 for(intj =1; J <=4I J + +) {Console.Write (" "); }                 for(intK =1; K <= i; k++) {Console.Write ("*"); } Console.WriteLine (""); } console.readkey ();

C # Foundation Day two-job answer-99 multiplication table-print stars

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.