标签:循环 else 语言 努力 str line 意思 闰年 ons
namespace C语言2
{
class Program
{
static void Main(string[] args)
{
//判断闰年
Console.Write("请输入年份:");
int i = int.Parse(Console.ReadLine());
if ((i % 4 == 0 && i % 100 != 0) || i % 400 == 0)
{
Console.WriteLine(i + "是闰年");
}
else
{
Console.WriteLine(i + "不是闰年");
}
//成绩
Console.Write("请输入您的成绩:");
int b = int.Parse(Console.ReadLine());
if (b < 0 || b > 100)
{
Console.WriteLine("输入的分数有误");
}
else if (b > 0 && b < 10)
{
Console.WriteLine("不及格!学渣!");
}
else if (b > 0 && b < 60)
{
Console.WriteLine("不及格!继续努力");
}
else if (b >= 60)
{
Console.WriteLine("恭喜你!及格了!");
}
else if (b >= 90)
{
Console.WriteLine("学霸!很厉害!");
}
//手势
Console.Write("请输入您的手势(石头/剪子/包袱):");
string c = Convert.ToString(Console.ReadLine());
Console.Write("请输入电脑的手势(石头/剪子/包袱):");
string d = Convert.ToString(Console.ReadLine());
if (c == "石头" && d == "石头")
{
Console.WriteLine("平局");
}
else if (c == "石头" && d == "剪子")
{
Console.WriteLine("用户赢了");
}
else if (c == "石头" && d == "包袱")
{
Console.WriteLine("电脑赢了");
}
else if (c == "剪子" && d == "剪子")
{
Console.WriteLine("平局");
}
else if (c == "剪子" && d == "石头")
{
Console.WriteLine("电脑赢了");
}
else if (c == "剪子" && d == "包袱")
{
Console.WriteLine("用户赢了");
}
else if (c == "包袱" && d == "包袱")
{
Console.WriteLine("平局");
}
else if (c == "包袱" && d == "剪子")
{
Console.WriteLine("电脑赢了");
}
else if (c == "包袱" && d == "石头")
{
Console.WriteLine("用户赢了");
}
Console.ReadLine();
Console.Write("请输入对话:");
string d = Convert.ToString(Console.ReadLine());
Console.Write("请输入电脑对话:");
string e = Convert.ToString(Console.ReadLine());
if (d == "你好" && e == "你好")
{
Console.WriteLine("你好");
}
else if (d == "你好" && e == "你也很好")
{
Console.WriteLine("你也很好");
}
Console.ReadLine();
// 判断年份
Console.Write("请输入年份:");
int year = Convert.ToInt32(Console.ReadLine());
if (year <= 0 || year > 9999)
{
Console.Write("您输入的年份有误");
}
else
{
Console.Write("请输入月份:");
int month = Convert.ToInt32(Console.ReadLine());
if (month < 1 || month > 12)
{
Console.Write("您输入的月份有误");
}
else
{
Console.Write("请输入日期:");
int day = Convert.ToInt32(Console.ReadLine());
if (day > 31 || day < 1)
{
Console.Write("您输入的日期有误");
}
else if ((month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) && (day > 0 && day <= 31))
{
Console.WriteLine("您输入的日期正确");
}
else if ((month == 4 || month == 6 || month == 9 || month == 11) && (day > 0 && day <= 30))
{
Console.WriteLine("您输入的日期正确");
}
else if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
{
if (month == 2 && (day > 0 && day <= 29))
{
Console.WriteLine("您输入的日期正确");
}
else
{
Console.WriteLine("您输入的日期有误");
}
}
else if (month == 2 && (day > 0 && day < 29))
{
Console.WriteLine("您输入的日期正确");
}
else
{
Console.WriteLine("您输入的日期有误");
}
Console.ReadLine();
}
}
Console.WriteLine("标准体重");
Console.WriteLine("男士体重(kg)=身高(cm)-100+-3");
Console.WriteLine("女士体重(kg)=身高(cm)-110+-3");
Console.Write("请输入您的性别:");
string xb = Console.ReadLine();
Console.Write("请输入您的身高:");
int height = Convert.ToInt32(Console.ReadLine());
Console.Write("请输入您的体重:");
int weight = Convert.ToInt32(Console.ReadLine());
if (xb == "男")
{
if (height - weight - 100 <= 3 && height - weight - 100 >= -3)
{
Console.WriteLine("恭喜您属于标准体重!");
}
else
{
Console.WriteLine("不好意思,您未达到标准体重!");
}
}
else
{
if (height - weight - 110 <= 3 && height - weight - 110 >= -3)
{
Console.WriteLine("恭喜您属于标准体重!");
}
else
{
Console.WriteLine("不好意思,您未达到标准体重!");
}
}
int m1 = 31, m2 = 28, m3 = 31, m4 = 30, m5 = 31, m6 = 30, m7 = 31, m8 = 31, m9 = 30, m10 = 31, m11 = 30;
Console.WriteLine("请输入月份");
int m = int.Parse(Console.ReadLine());
Console.WriteLine("请输几号");
int d = int.Parse(Console.ReadLine());
switch (m)
{
case 1:
Console.WriteLine("第" + d.ToString() + "天");
break;
case 2:
Console.WriteLine("第" + (m1 + d).ToString() + "天");
break;
case 3:
Console.WriteLine("第" + (m1 + m2 + d).ToString() + "天");
break;
case 4:
Console.WriteLine("第" + (m1 + m2 + m3 + d).ToString() + "天");
break;
case 5:
Console.WriteLine("第" + (m1 + m2 + m3 + m4 + d).ToString() + "天");
break;
case 6:
Console.WriteLine("第" + (m1 + m2 + m3 + m4 + m5 + d).ToString() + "天");
break;
case 7:
Console.WriteLine("第" + (m1 + m2 + m3 + m4 + m5 + m6 + d).ToString() + "天");
break;
case 8:
Console.WriteLine("第" + (m1 + m2 + m3 + m4 + m5 + m6 + m7 + d).ToString() + "天");
break;
case 9:
Console.WriteLine("第" + (m1 + m2 + m3 + m4 + m5 + m6 + m7 + m8 + d).ToString() + "天");
break;
case 10:
Console.WriteLine("第" + (m1 + m2 + m3 + m4 + m5 + m6 + m7 + m8 + m9 + d).ToString() + "天");
break;
case 11:
Console.WriteLine("第" + (m1 + m2 + m3 + m4 + m5 + m6 + m7 + m8 + m9 + m10 + d).ToString() + "天");
break;
case 12:
Console.WriteLine("第" + (m1 + m2 + m3 + m4 + m5 + m6 + m7 + m8 + m9 + m10 + m11 + d).ToString() + "天");
break;
default:
Console.WriteLine("有误");
break;
}
Console.Write("请输入24小时制的时间0-24:");
int time = Convert.ToInt32(Console.ReadLine());
if (time >= 0 && time <= 24)
{
if (time >= 0 && time <= 6)
{
Console.Write("凌晨" + time + "点");
}
else if (time > 6 && time <= 12)
{
Console.Write("上午" + time + "点");
}
else if (time > 12 && time <= 22)
{
Console.Write("下午" + (time - 12) + "点");
}
}
}
}
}
标签:循环 else 语言 努力 str line 意思 闰年 ons
原文地址:http://www.cnblogs.com/yujiamin123/p/6979245.html