VS学习笔记3 (0413)

内容:

1)输入年和月,确定有几天

static void Main001(string[] args)
{
int yue;
int nian;
Console.WriteLine("请输入月份");
yue=Convert.ToInt32(Console.ReadLine());
Console.WriteLine("请输入年份");
nian = Convert.ToInt32(Console.ReadLine());


if(yue==1||yue==3||yue==5||yue==7||yue==8||yue==10||yue==12)
{
Console.Write("本月有31天");

}
else if(yue==4||yue==6||yue==9||yue==11)
{
Console.Write("本月有30天");
}
else if(yue==2)
{
if (nian % 400 == 0 || nian % 4 == 0 && nian % 100 != 0)
{
Console.Write("本月有29天");
}
else
{
Console.Write("本月有28天");
}

}

else
{
Console.Write("输入有误");
}

}
static void Main002(string[] args)
{
int year;
int mon;
int day;
Console.WriteLine("请输入年份:");
year = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("请输入月份:");
mon = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("请输入日期:");
day = Convert.ToInt32(Console.ReadLine());
if(mon==1||mon==3||mon==5||mon==7||mon==8||mon==10||mon==12)
{
if (day <= 31&&day>0)
{
Console.WriteLine("您的输入正确");
}
else
{
Console.WriteLine("输入有误");
}

}
else if (mon == 4 || mon == 6 || mon == 9 || mon == 11)
{
if (day <= 30 && day > 0)
{
Console.WriteLine("您的输入正确");
}
else
{
Console.WriteLine("输入有误");
}
}

else if (mon == 2)
{
if (year % 400 == 0 || year % 4 == 0 && year % 100 != 0)
{
if (day <= 29 && day > 0)
{ Console.WriteLine("输入正确"); }
else
{ Console.WriteLine("输入有误"); }
}
else
{
if (day <= 28 && day > 0)
{
Console.WriteLine("输入正确");
}
else
{
Console.WriteLine("输入有误");
}


}

}
else { Console.WriteLine("错"); }

}

  2)求一元二次方程

static void Main003(string[] args)
{
int a;
int b;
int c;
int det;
Console.WriteLine("求一元二次方程,");
Console.WriteLine("请输入b值");
Console.WriteLine("请输入c值");
Console.WriteLine("请输入a值");
a =Convert.ToInt32( Console.ReadLine());
b = Convert.ToInt32(Console.ReadLine());
c = Convert.ToInt32(Console.ReadLine());
det = b * b - 4 * a * c;
if (a == 0)
{
Console.WriteLine("该式不成立");

}

else
{
if(det>0)
{
Console.WriteLine("");

}
else if (det == 0) { }
else { }

}

}
3)测试体重

static void Main(string[] args)
{
int sg;
int tz;
int t;
Console.WriteLine("性别");
String xb = Console.ReadLine();
Console.WriteLine("体重");
tz=Convert.ToInt32(Console.ReadLine());
Console.WriteLine("身高");
sg=Convert.ToInt32(Console.ReadLine());

if(xb=="男")
{
t= tz - sg + 100;
if(t<=3&&t>=-3)
{
Console.WriteLine("真长");
}
else if(t<-3)
{
Console.WriteLine("太瘦");
}
else if(t>3)
{
Console.WriteLine("太胖");
}


}
else if (xb == "女")
{
t = tz - sg + 110;
if (t <= 3 && t >= -3)
{
Console.WriteLine("真长");
}
else if (t < -3)
{
Console.WriteLine("太瘦");
}
else if (t > 3)
{
Console.WriteLine("太胖");
}
}

else
{
Console.WriteLine("错");
}
}


}

转载于:https://www.cnblogs.com/koker/p/5388725.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值