lesson02_quiz

本文提供了一系列C#控制台应用程序的练习实例,包括数值比较、条件判断、字符输入处理等,帮助初学者掌握基本的编程逻辑和语法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

using System;


namespace lesson02_zy
{
class MainClass
{
public static void Main (string[] args)
{
//练习1
// 从控制台输入3个数字a,b,c,用逻辑运算符判断一下a是否是最
// 大数,如果是输出“YES”,否则输出“NO”。
// string str = Console.ReadLine ();
// string[] data = str.Split(' ');
//
// int a = int.Parse (data [0]);
// int b = int.Parse (data [1]);
// int c = int.Parse (data [2]);
//
//
// if (a > b && a > c) {
// Console.WriteLine ("YES");
// } else {
// Console.WriteLine ("NO");
// }




// //练习2
// 从控制台输入一个整数,如果该数大于10,则输出该数的二倍,否则,什么都不
//
// int n =Convert.ToInt32(Console.ReadLine());
// if (n > 10) {
// Console.WriteLine (n*2);
// }


// //练习3
// 控制台输入一个字符,如果输入的是m,则输出男性,否则什么都不输出。
// • 如果从控制台输入一个字符,如果输入的是m,则输出男性,否则输出
// 女性,那怎么实现呢?
// string x = Console.ReadLine();
// if (x == "m") {
// Console.WriteLine ("男性");
//
// } else {
// Console.WriteLine ("女性");
// }



//练习4
// • 从控制台输入两个整数,并输出两个数中的最大值。
// • 从控制台输入两个小数,并输出两个数中的最小值。
// string strmax = Console.ReadLine();
// string[] datamax = strmax.Split (' ');
// int x = int.Parse (datamax [0]);
// int y = int.Parse (datamax [1]);
// if (x > y) {
// Console.WriteLine (x);
// } else {
// Console.WriteLine (y);
// }
// string strmin = Console.ReadLine();
// string[] datamin = strmin.Split (' ');
// float m = float.Parse (datamin [0]);
// float n = float.Parse (datamin[1]);
// if (m > n) {
// Console.WriteLine (n);
// } else {
// Console.WriteLine (m);
// }




// //练习5
// • 输入一个年份,判断该年份是否是闰年?如果是闰年,则输出该年是闰年,否则
// 输出该年不是闰年。
// • 闰年:能被400整除或者(能被4整除,但是不能被100整除)。
// int year =Convert.ToInt32( Console.ReadLine());
// if (year % 4 == 0 && year % 100 != 0) {
// Console.WriteLine ("{0}年是闰年",year);
// } else {
// if (year % 400 == 0) {
// Console.WriteLine ("{0}年是闰年",year);
// }else{
// Console.WriteLine ("{0}年不是闰年",year);
// }
// }




// //练习6
// 使用条件运算符,完成求两个数的最大值。
// string strnum = Console.ReadLine();
// string[] datanum = strnum.Split (' ');
// float a = float.Parse (datanum [0]);
// float b = float.Parse (datanum [1]);
// float max = a>b?a:b;
// Console.WriteLine (max);


// //练习7 
// 从键盘输入一个字符,如果是数字打印this is digital,如果是大写字母,打印
// this is capital letter,如果是小写字母,打印this is letter,如果是其他字符,
// 打印other。
// int n = Console.Read();
// if (n >= 65 && n <= 90) {
// Console.WriteLine ("this is capital letter");
// } else {
// if (n >= 97 && n <= 122) {
// Console.WriteLine ("this is letter");
// } else {
// if (n >= 48 && n <= 97) {
// Console.WriteLine ("this is digital");
// } else {
// Console.WriteLine ("other");
// }
// }
// }


// //练习8
// 从键盘输入三个整数,并输出最大值。
// string thnum = Console.ReadLine();
// string[] thdata = thnum.Split (' ');
// int a = int.Parse (thdata [0]);
// int b = int.Parse (thdata [1]);
// int c = int.Parse (thdata [2]);
// if (a > b) {
// if (a > c) {
// Console.WriteLine (a);
// } else {
// Console.WriteLine (c);
// }
// } else {
// if (b > c) {
// Console.WriteLine (b);
// } else {
// Console.WriteLine (c);
// }
// }




// //练习9
// • 从控制台输入1~4,对应打出春夏秋冬的英文词。
// int n = Convert.ToInt32(Console.ReadLine());
// switch (n) {
// case 1:{Console.WriteLine ("spring");break;}
// case 2:{Console.WriteLine ("summer");break;}
// case 3:{Console.WriteLine ("autumn");break;}
// case 4:{Console.WriteLine ("winter");break;}
// default:{Console.WriteLine ("请输入1-4");break;}
// }










}
}
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值