C # Fourth session

Source: Internet
Author: User

Score Statement (1)

Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Text;
Using System.Threading.Tasks;

Namespace Fenzhiyuju1
{
Class Program
{
static void Main (string[] args)
{
Statement classification: Sequential statements, SELECT statements (branch statements), loop statements
Select, Branch statement
if () {}
int a = 10;
if (a < 10) {
a++;

//}
if (a>3) {
a--;
//}
Console.WriteLine (a);


if () {}else{}
If the if is set up, only go if not go else
If not, then go else not go if
int a = 10;
if (a > 3)
//{
a--;
//}
Else
//{
a++;
//}
Console.WriteLine (a);

if () {}else if () {}else if () {}else{} multiple Select one
If not, go to see the next else if the establishment is not established, if set up, the rest will not be executed, if not set up continue to run down
int a = 10;
if (a>12)
//{
a++;
//}
else if (a < 3)
//{
a++;
//}
Else
//{
a++;
//}


Nesting of If
if ()
//{
if ()
// {
//
// }
Else
// {
// }
// }
int a = 10;
if (a < 100)
//{
if (a > 3 && a < 20)
// {
a++;
// }
//}
Else
//{
a--;
//}

//Contact
//Enter an integer less than or equal to 100, judging:
//is less than 10
//two-digit
//is//console.write ("Please enter an integer less than or equal to 100:");
int a = Int. Parse (Console.ReadLine ());
//if (a <=)
//{
//if (a <)
//{
//Console.WriteLine ("You have entered a number less than 10");
//}
// else if (a <)
//{
//Console.WriteLine ("You entered a two-digit number");
//}
//Else
//{
//Console.writeli NE ("You have entered 100");
//}
//}
//else
//{
///Console.WriteLine ("Error entered by You");
//}
//Enter three integers, xyz, and eventually output in small to large mode.
//Take advantage of nesting.
for (;;)
{
//Console.WriteLine ("Please enter X:");
//Double X = double. Parse (Console.ReadLine ());
//Console.WriteLine ("Please enter Y:");
//Double Y = double. Parse (Console.ReadLine ());
//Console.WriteLine ("Please enter Z:");
//Double Z = double. Parse (Console.ReadLine ());

if (X > Y)
//{
if (X > Z)
// {
if (Y > Z)
// {
Console.WriteLine ("Z<y<x");
// }
Else
// {
Console.WriteLine ("Y<z<x");
// }
// }
Else
// {
Console.WriteLine ("Y<x<z");
// }
//}
else if (X > Z)
//{
Console.WriteLine ("Z<x<y");
//}
Else
//{
if (Z > Y)
// {
Console.WriteLine ("X<y<z");
// }
Else
// {
Console.WriteLine ("X<z<y");
// }
//}

Enter two numbers, give the value of a to B, give the value of B to a
Intermediate variables
int a = 2;
int b = 5;
int zhong = A;
A = b;
b = Zhong;


Enter three integers, xyz, and eventually output from small to large.
Console.WriteLine (x);
Console.WriteLine (y);
Console.WriteLine (z);
Using intermediate variables
Double A = X;
if (x < Y && x < Z)
// {
if (y>z)
// {
A = Z;
Z = Y;
Y = A;
// }
// }
else if (Y < X && y < Z)
// {
if (X > Z)
// {
X = Y;
Y = Z;
Z = A;
// }
Else
// {
X = Y;
Y = A;
// }
// }
Else
// {
if (X > Y)
// {
X = Z;
Z = A;
// }
Else
// {
X = Z;
Z = Y;
Y = A;
// }
// }

Console.WriteLine ("Output Order:");
Console.WriteLine (X);
Console.WriteLine (Y);
Console.WriteLine (Z);

Console.WriteLine ("Hello, do you have a room?") ");
String a = Console.ReadLine ();
if (A = = "has" | | a== "Yes" | | a== "Of course there is" | | a== "Required" | | a== "Nonsense" | | a== "must have" | | a== "must have ah" | | a== "There is there" | | a== "must have Ah")
{
Console.WriteLine ("Let's Get Married");
Console.WriteLine ("OK, replace one");
}
Else
{
Console.WriteLine ("Do you have a deposit?") ");
String B = Console.ReadLine ();
if (b = = "have" | | b = "Yes" | | b = = "Yes" | | b = = "must" | | b = "nonsense" | | b = "There must be" | | b = "There must be" | | b== "must have Ah")
{
Console.WriteLine ("You take the deposit to buy a house, let's get married Again");
Console.WriteLine ("OK, replace one");
}
Else
{
Console.WriteLine ("Do you have the ability?");
String c = Console.ReadLine ();
if (c = = "Have" | | c = "Yes" | | c = = "Yes" | | c = = "must" | | c = "nonsense" | | c = "There must be" | | c = "There must be." | | c== "must have Ah")
{
Console.WriteLine ("You make money first, then you have money to buy a house, let's talk about getting married again.");
Console.WriteLine ("OK, replace one");
}
Else
{
Console.WriteLine ("Goodbye");
Console.WriteLine ("OK, replace one");
}
}
}

}


Console.WriteLine ();
}
}
}

C # Fourth session

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.