• c#基础练习


    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();

            }
        }
    }

  • 相关阅读:
    对“一道有趣的题目”的解答
    在Debian中使用Notify
    Debian服务器安装详细流程
    Lighttpd1.4.20源码分析之插件系统(1)plugin结构体和插件接口
    Lighttpd1.4.20源码分析之etag.c(h) HTTP/1.1中的Etag域
    Lighttpd1.4.20源码分析之bitset.c(h) 位集合的使用
    伸展树
    GCC中的弱符号与强符号
    Lighttpd1.4.20源码分析之fdevent系统(3) 使用
    Lighttpd1.4.20源码分析之插件系统(3)PLUGIN_TO_SLOT宏
  • 原文地址:https://www.cnblogs.com/dyllove98/p/3144910.html
Copyright © 2020-2023  润新知