练习05判断分数
using System;
namespace 判断练习
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("请输入数学成绩");
string score_math = Console.ReadLine();
Console.WriteLine("请输入语文成绩");
string score_chinese = Console.ReadLine();
int score_math_1 = Convert.ToInt32(score_math);
int score_chinese_1 = Convert.ToInt32(score_chinese);
bool a = score_math_1 > 90 && score_chinese_1 > 90;
//Console.WriteLine(score_math_1);
//Console.WriteLine(a);
bool b = score_chinese_1 > 90 || score_chinese_1 > 90;
Console.WriteLine("老苏的语文和数学都大于90:\t{0}\n老苏的语文和数学有一门大于90:\t{1}", a, b);
Console.ReadKey();
}
}
}
练习06判断闰年
using System;
namespace 练习06判断闰年
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("请输入年份:");
int year = Convert.ToInt32(Console.ReadLine());
bool tiao1 = year % 400 == 0;
bool tiao2 = year % 4 == 0 && year % 100 != 0;
bool rest = tiao1 || tiao2;
Console.WriteLine("你输入的是{0}年,这年是否为闰年:{1}",year, rest);
Console.ReadKey();
}
}
}
练习07三元运算判断账号
using System;
namespace 练习07三元运算判断账号
{
class Program
{
static void Main(string[] args)
// 模拟输入账号密码,如果输入正确则提示正确,否则提示错误。账号:123 密码:456
{
Console.WriteLine("请输入账号");
string count = Console.ReadLine();
Console.WriteLine("请输入密码");
string psd = Console.ReadLine();
bool rest_count = count == "123" ? true : false;
bool rest_psd = psd == "456" ? true : false;
string rest = rest_count && rest_psd == true ? "登陆成功!" : "登陆失败!";
Console.WriteLine(rest);
Console.ReadKey();
}
}
}