Statement (while/do while/try catch finally)

Source: Internet
Author: User

 

/*While

Int n = 1;// If it is a for loop, for (INT n = 1; n <6; n ++)

While (n <6)

{Console. writeline ("the result is {0}", n); // the representation of null!

// Console. Write ("I am: {0}, you are: {1}, We: {2}", a, B, c); pay attention to the format! Separated by, and arranged in order.

N ++; // increment from n = 1!

If (n = 6)

{

Continue; // jump out of the current cycle and return the judgment Condition

}

If (n = 9)

{

Break; // terminate the cycle directly!

}

}

Console. Readline ();*/

/*//Do whileUsage!

Int x = 0;
Do
{
Console. writeline (x); // run the command first to determine whether the conditions are met!
X ++;
}While (x <5 );


Console. Readline ();*/

Try, catch, finally

 

Try // test.
{
Int I = int. parse (console. Readline ());
Console. writeline ("there is no exception here, You can print it! ");
}
Catch(Exception E)// Catch error! Exception indicates an error that occurs during application running.
{
Console. writeline ("this is an error. Please report it! ");
}
Finally// Run regardless of whether an error occurs!
{
Console. writeline ("thank you .");
}
Console. Readline ();

 

/* // Badminton rackets 15, badminton 3, water 2, total 200. // Use the exhaustive method to obtain a combination that meets the conditions!

// 13 66 100

Int A = 0;

For (INT x = 1; x <= 13; X ++)

{

For (INT y = 1; y <= 66; y ++)

{

For (INT z = 1; Z <= 100; Z ++)

{

If (15 * x + 3 * Y + 2 * z = 200) // If statement used to determine whether the condition is met!

{A = ++ ;}

Console. writeline ("Pai" + x + "Qiu" + Y + "Shui" + Z );

// Output the value of the combination that meets the condition!

}

}

}

Console. Write ("zonggong" + );//A indicates the total number of combinations!

Console. Readline ();*/

 

 

/* // 2 RMB, 3 RMB, and 5 RMB to 50 RMB!

// 25 16 10 (maximum)

Int I = 0;

For (int A = 0; A <= 25; A ++)

{For (INT B = 0; B <= 16; B ++)

{For (int c = 0; C <= 10; C ++)

{

If (2 * A + 3 * B + 5 * c = 50)

{I = ++ I;

Console. writeline ("A" + A + "B" + B + "C" + C );

}

}

}

}

Console. writeline ("zonggong" + I );

Console. Readline ();*/

/* // Rooster 2 yuan, hen 1 yuan, chicken 0.5 yuan, each minimum has been, please 100 yuan to buy 100 chicken all possible

Int A = 0;

For (int g = 1; G <= 50; G ++)

{For (int m = 1; m <= 100; m ++)

{For (INT x = 1; X <= 200; X ++)

{

If (2 * g + 1 * m + 0.5 * x = 100 & G + M + x = 100)

{A = ++;

Console. writeline ("G" + G + "M" + M + "X" + x );

}

}

}

}

Console. writeline ("Total" + );

Console. Readline (); * // 33!

 

Statement (while/do while/try catch finally)

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.