01总结
02代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _05_ifelse的四个练习_1
{
class Program
{
static void Main(string[] args)
{
比较三个数字的大小,不考虑相等
//Console.WriteLine("请输入第1个数字:");
//int no1 = Convert.ToInt32(Console.ReadLine());
//Console.WriteLine("请输入第2个数字:");
//int no2 = Convert.ToInt32(Console.ReadLine());
//Console.WriteLine("请输入第3个数字:");
//int no3 = Convert.ToInt32(Console.ReadLine());
//if (no1 > no2 && no1 > no3)
//{
// Console.WriteLine("第1个数字最大!");
//}
//else if (no2 > no1 && no2 > no3)
//{
// Console.WriteLine("第2个数字最大!");
//}
//else
//{
// Console.WriteLine("第3个数字最大!");
//}
//Console.ReadKey();
//输入用户名和密码,若不正确再输一遍
//Console.WriteLine("请输入用户名:");
//string name = Console.ReadLine();
//Console.WriteLine("请输入密码:");
//string pwd = Console.ReadLine();
//bool b = name == "孙晓雪" && pwd == "123";
//if (b)
//{
// Console.WriteLine("登陆成功!");
//}
//else
//{
// Console.WriteLine("用户名或密码输入有误!\n请重新输入!");
// Console.WriteLine("请输入用户名:");
// name = Console.ReadLine();
// Console.WriteLine("请输入密码:");
// pwd = Console.ReadLine();
// if (b)
// {
// Console.WriteLine("登陆成功!");
// }
// else
// {
// Console.WriteLine("已经输错两次,无法登陆!");
// }
//}
//Console.ReadKey();
}
}
}
namespace _04_if的三个练习_1
{
class Program
{
static void Main(string[] args)
{
//让用户输入一个年龄,若大于(含)30岁,提示用户该谈恋爱了
//Console.WriteLine("请输入你的年龄");
//int age = Convert.ToInt32(Console.ReadLine());
//if (age >= 30)
//{
// Console.WriteLine("你该谈恋爱了吧!");
//}
//else
//{
// Console.WriteLine("好好工作去吧,想什么乱起八糟恋爱!");
//}
//Console.ReadKey();
//语文成绩大于90,数学大于90,称之为优秀
//语文成绩100,数学100,奖励今天不用写作业
//Console.WriteLine("请输入你的语文成绩");
//int chinese = Convert.ToInt32(Console.ReadLine());
//Console.WriteLine("请输入你的数学成绩");
//int math = Convert.ToInt32(Console.ReadLine());
//if (chinese >= 90 && math >= 90)
//{
// Console.WriteLine("你怎么这么优秀!");
// if(chinese ==100 && math==100)
// {
// Console.WriteLine ("你简直太优秀了,今天不用写作业了!");
// }
//}
//else
//{
// Console.WriteLine ("继续加油就好了!");
//}
//Console.ReadKey();
//若登录名位123,密码为123,则宣布登陆成功
Console.WriteLine("请输入用户名:");
string name = Convert.ToString(Console.ReadLine());
Console.WriteLine("请输入密码:");
string password = Convert.ToString(Console.ReadLine());
//string 类型其实就不用转换了,接收也是string类型
bool b = name == "123" && password == "123";
if (b)
{
Console.Write("登陆成功!");
}
else if (name != "123")
{
Console.WriteLine("用户名输入有误!");
}
else
{
Console.WriteLine("密码输入有误!");
}
Console.ReadKey();
}
}
}
namespace prac04
{
class Program
{
static void Main(string[] args)
{
Console.Write("请任意输入一个天数:");
int days =Convert.ToInt32(Console.ReadLine());
int weeks = days / 7;
int day = days % 7;
Console.WriteLine("{0}天是{1}周零{2}天", days, weeks, day);
Console.ReadKey();
}
}
}
namespace yearpractice
{
class Program
{
static void Main(string[] args)
{
//判断闰年的练习
Console.WriteLine("请输入年份:");
int year = Convert.ToInt32(Console.ReadLine());
//能背400整除,或者能被4整除但不能被100整除
bool b = year % 400 == 0 || (year % 4 == 0 && year % 100 != 0);
//bool类型输出结果
Console.WriteLine (b);
Console .ReadKey ();
}
}
}
namespace _03_判断平年闰年_2
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("请输入一个年份:");
int year = Convert.ToInt32(Console.ReadLine());
if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0))
{
Console.WriteLine("{0}年是闰年!",year );
}
else
{
Console.WriteLine("{0}年是平年",year );
}
Console.ReadKey();
}
}
}
namespace practice02
{
class Program
{
static void Main(string[] args)
{
//编程实现...秒是几天零几小时几分几秒
Console.WriteLine("请输入秒数:");
int seconds = Convert.ToInt32(Console.ReadLine());
//一天等于60*60*24=86400秒
int days = seconds / 86400;//求得天数
int secs=seconds %86400;//剩余秒数
int hours = secs / 3600;//求得小时数
secs = secs % 3600;
int minitues = secs / 60;//求得分钟数
secs = secs % 60;//求得秒数
Console.WriteLine("{0}秒有{1}天零{2}小时{3}分{4}秒", seconds, days, hours, minitues, secs);
Console.ReadKey();
}
}
}