using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace 第四讲1
{
class Program
{
static void Main(string[] args)
{
Console.Write(10 / 3 * 1.0);
decimal PI = 3.14m;
double pi = (double)PI;
Console.ReadKey();
int TX = 35;
int KZ = 50;
int sum = TX * 3 + KZ * 2;
int pay = (int)(sum * 0.88);
Console.Write(10 / 3 * 1.0);
// 1.让用户输入一个学生的姓名,以及三门功课的成绩,之后通过程序计算出该学生的总成绩和平均成绩并输入。Xxx的总成绩为xxx,平均成绩为xxx。
//如果用户输入有错怎么防?
try
{
Console.Write(" 输入学生姓名:");
string name = Console.ReadLine();//接收用户输入的内容
Console.Write(" 输入数学成绩:");
int math = Convert.ToInt32(Console.ReadLine());
Console.Write(" 输入语文成绩:");
int chinese = Convert.ToInt32(Console.ReadLine());
Console.Write(" 输入英语成绩:");
int english = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("{0}的三门课程总成绩为{1},平均成绩为{2}", name, math + chinese + english, (math + chinese + english) / 3);
}
catch {
Console.WriteLine("您输入的成绩有误,请如入100以内的正整数。");
}
// 2.编程实现:用户输入一个天数(如46天),程序算出是几周零几天。并且在控制台输出
Console.WriteLine("请输入天数:");
int days = Convert.ToInt32(Console.ReadLine());
int weeks = days / 7;
int day = days % 7;
Console.WriteLine("{0}天中有{1}星期零{2}天", days, weeks, day);
// 3.编程实现用户输入的一个秒数(10765326878657秒),计算出是几天几个小时几分钟几秒中,并在控制台输入
Console.WriteLine("请输入秒数数:");
int seconds = Convert.ToInt32(Console.ReadLine());
int days = seconds / (3600 * 24);
int mod = seconds % (3600 * 24);//得到出去上面天的秒数之外剩下的秒数
int houres = mod / 3600;//等下的秒数中有多少个3600秒,就是有多少个小时。
mod = mod % 3600;//得到剩下的秒数中出去上面的小时的秒数还剩多少秒。
int min = mod / 60;//得到剩下的秒数中有多少个60秒,就是有多少分钟。
int second = mod % 60;
Console.WriteLine("{0}秒中有{1}天,{2}小时,{3}分钟,{4}秒。", seconds, days, houres, min, second);
//4.使用计算机描述张三(20岁)比李四(18)小,这句话的结果。
int zsAge = 20;
int lsAge = 18;
bool isRright = zsAge != lsAge;
Console.WriteLine(isRright);
Console.ReadKey();
}
}
}