Judge three numbers who are to large:
Static voidMain (string[] args) {Console.WriteLine ("Please enter the first number:"); intA =Convert.ToInt32 (Console.ReadLine ()); Console.WriteLine ("Please enter a second number:"); intb =Convert.ToInt32 (Console.ReadLine ()); Console.WriteLine ("Please enter a third number:"); intc =Convert.ToInt32 (Console.ReadLine ()); if(A >=b) {if(A >=c) {Console.WriteLine ("the three largest numbers are:"+a); } Else{Console.WriteLine ("the three largest numbers are:"+c); } } Else { if(b >=c) {Console.WriteLine ("three of the largest are"+b); } Else{Console.WriteLine ("three of the largest are"+c); } } }
To determine the parity of a number:
Static voidMain (string[] args) {Console.Write ("Enter a number:"); intA =int. Parse (Console.ReadLine ()); if(a%2==0) {Console.Write ("This number is even ."); } Else{Console.Write ("This number is odd ."); } console.readline (); }
To judge leap years:
Static voidMain (string[] args) {Console.WriteLine ("Please enter the year:"); intYear =int. Parse (Console.ReadLine ()); if(Year% -==0|| Year%4==0&& Year%4!=0) {Console.Write ( year+"is a leap year"); } Else{Console.Write ( year+"It's common year ."); } }
Mobile Customer Service:
Static voidMain (string[] args) {Console.WriteLine ("Check the telephone rate by 1, check the flow according to 2, manual service Press 3, Business processing Press 4,");intA =Convert.ToInt32 (Console.ReadLine ());Switch(a) { Case 1: {Console.WriteLine ("you have a lot of charges, no recharge."); Break;} Case 2: {Console.WriteLine ("flow can also support"); Break;} Case 3: {Console.WriteLine ("Please wait while the manual service is full"); Break;} Case 4: {Console.WriteLine ("Sorry, I can't handle it"); Break;}default: {Console.WriteLine ("you entered the wrong"); Break;}}}
The game then chooses the hero:
Static voidMain (string[] args) {Random a=NewRandom (); intb = A.next (5); stringhero; Switch(b) { Case 1: {Hero="Ezreal"; Break; } Case 2: {Hero="Lacus"; Break; } Case 3: {Hero="Galen"; Break; } Case 4: {Hero="Tim Mo"; Break; } default: {Hero="Tristana"; Break; }} Console.WriteLine ("the heroes you choose are:"+ Hero +", please be prepared to start"); }
Conditional Statement Instance