标签:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace day03
{
class Program
{
static void Main(string[] args)
{
/* int x = Convert.ToInt32(Console.ReadLine());
// Console.WriteLine(x == 0 ? "x=0" : "x!=0");
if (x==0)
{
Console.WriteLine("x=0");
}
else
{
Console.WriteLine("x!=0");
}
Console.ReadKey();
//分数的分类
Console.WriteLine("请输入姓名");
Console.ReadLine();
Console.WriteLine("请输入分数");
double a = Convert.ToDouble(Console.ReadLine());
if (a<50&&a>0)
{
Console.WriteLine("使劲努力,不要偷懒");
}
else if (a >= 50 && a < 60)
{
Console.WriteLine("就差一点点,再加把劲");
}
else if (a>=60&&a<=100)
{
Console.WriteLine("恭喜你及格了");
if (a>80)
{
Console.WriteLine("你学的不错值得表扬!");
}
}
else
{
Console.WriteLine("您输入的分数有误");
}
Console.ReadKey();
//标准体重的计算
Console.WriteLine("请输入性别");
string a=Console.ReadLine();
Console.WriteLine("请输入体重");
double b = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("请输入身高");
double c = Convert.ToDouble(Console.ReadLine());
double d;
if (a=="男")
{
d = b - c + 100;
}
else
{
d = b - c + 110;
}
if (d>3)
{
Console.WriteLine("您超重了");
}
else if (d<-3)
{
Console.WriteLine("您需要增加营养");
}
else
{
Console.WriteLine("您的体重为标准体重");
}
Console.ReadKey();
//闰年的算法1
Console.WriteLine("请输入一个年份");
int y = Convert.ToInt32(Console.ReadLine());
if ((y%4==0&&y%100!=0)||y%400==0)
{
Console.WriteLine(y + "年2月29日存在");
}
else
{
Console.WriteLine(y + "年2月29日不存在");
}
Console.ReadKey();
//算法2
Console.WriteLine("请输入年份");
int y = Convert.ToInt32(Console.ReadLine());
if (y % 4!= 0)
{
Console.WriteLine("该年份不是闰年");
}
else
{
if (y%100 !=0)
{
Console.WriteLine("该年份是闰年");
}
else if (y%400!=0)
{
Console.WriteLine("该年份不是闰年");
}
else
{
Console.WriteLine("该年份是闰年");
}
}
Console.ReadKey();
*
* //结婚的例子1
Console.WriteLine("你有房吗");
string a = Console.ReadLine();
if (a=="有")
{
Console.WriteLine("你有车吗");
string b = Console.ReadLine();
if (b=="有")
{
Console.WriteLine("你有钱吗");
string c = Console.ReadLine();
if (c=="有")
{
Console.WriteLine("我们结婚吧");
}
else
{
Console.WriteLine("以后要好好工作努力赚钱");
}
}
else
{
Console.WriteLine("抓紧时间给我买辆车");
}
}
else
{
Console.WriteLine("慢走不送");
}
Console.ReadKey();
}
*
*
//例子2
Console.ReadKey();
//输出三个数中最大的数
Console.WriteLine("请输入三个数");
int a, b, c,d;
a = Convert.ToInt32(Console.ReadLine());
b = Convert.ToInt32(Console.ReadLine());
c = Convert.ToInt32(Console.ReadLine());
if (a>b&&a>c)
{
d = a;
}
else if (b > a && b > c)
{
d = b;
}
else
{
d = c;
}
Console.WriteLine("最大的数是" + d);
Console.ReadKey();
Console.WriteLine("请选择7以内的一个数");
int a = Convert.ToInt32(Console.ReadLine());
string x;
switch (a)
{
case 1:
x = "选择的是星期一";
break;
case 2:
x = "选择的是星期二";
break;
case 3:
x = "选择的是星期三";
break;
case 4:
x = "选择的是星期四";
break;
case 5:
x = "选择的是星期五";
break;
case 6:
x = "选择的是星期六";
break;
case 7:
x = "选择的是星期天";
break;
default:
x = "选择的是默认";
break;
}
Console.WriteLine(x);
Console.ReadKey();
*/
//猜拳的算法
Random r = new Random();
string x, y;
int a = r.Next(0, 3);
int b = r.Next(0, 3);
switch (a)
{
case 0:
x = "剪刀";
break;
case 1:
x = "石头";
break;
case 2:
x = "布";
break;
default:
x = "耍赖";
break;
}
switch (b)
{
case 0:
y = "剪刀";
break;
case 1:
y = "石头";
break;
case 2:
y = "布";
break;
default:
y = "耍赖";
break;
}
Console.WriteLine("x出的是" + x);
Console.WriteLine("y出的是" + y);
string jg = "";
if (a == b)
{
jg="平局";
}
else if (a>b)
{
if (a==2&&b==0)
{
jg="y胜利";
}
else
{
jg="x胜利";
}
}
else if (b>a)
{
if (a==0&&b==2)
{
jg="x胜利";
}
else
{
jg="y胜利";
}
}
Console.WriteLine(jg);
Console.ReadKey();
}
}
}
标签:
原文地址:http://www.cnblogs.com/William-1234/p/4307905.html