24661人加入学习
(72人评价)
C#编程-第一季-编程基础-宇宙最简单2021最新版

制作完成于2021年10月10日,使用Visual Studio 2019

价格 免费

 

using System;

namespace _017_编程题
{
    class Program
    {
        static void Main(string[] args)
        {
            int x = 1, a = 0, b = 0;
            switch (x)
            {
                case 0: b++; break;
                case 1: a++; break;
                case 2: a++; b++; break;
            }
            Console.WriteLine("a=" + a + " b=" + b);
        }
    }
}

 

[展开全文]
using System;

namespace _017_编程题
{
    class Program
    {
        static void Main(string[] args)
        {
            //// a b c d
            //int a = Convert.ToInt32(Console.ReadLine());
            //int b = Convert.ToInt32(Console.ReadLine());
            //int c = Convert.ToInt32(Console.ReadLine());
            //int d = Convert.ToInt32(Console.ReadLine());

            //int max = a, min = a;
            //if (max < b)
            //{
            //    max = b;
            //}
            //if (max < c)
            //{
            //    max = c;
            //}
            //if (max < d)
            //{
            //    max = d;
            //}

            //if (min > b)
            //{
            //    min = b;
            //}
            //if (min > c)
            //{
            //    min = c;
            //}
            //if (min > d)
            //{
            //    min = d;
            //}

            //Console.WriteLine("最大值是{0},最小值是{1}", max, min);


            //int a = Convert.ToInt32(Console.ReadLine());
            //int b = Convert.ToInt32(Console.ReadLine());

            //int op = Convert.ToInt32(Console.ReadLine());

            //int res = 0;
            //switch (op)
            //{
            //    case 0:
            //        res = a + b;
            //        Console.WriteLine(res);
            //        break;
            //    case 1:
            //        res = a - b;
            //        Console.WriteLine(res);
            //        break;
            //    case 2:
            //        res = a * b;
            //        Console.WriteLine(res);
            //        break;
            //    case 3:
            //        double res2 = a * 1.0 / b;
            //        Console.WriteLine(res2);
            //        break;
            //}


            int x = 1, a = 0, b = 0;
            switch (x)
            {
                case 0: b++; break;
                case 1: a++; break;
                case 2: a++; b++; break;
            }
            Console.WriteLine("a=" + a + " b=" + b);
        }
    }
}

 

[展开全文]
using System;

namespace _016_switch分支语句
{
    class Program
    {
        static void Main(string[] args)
        {
            int weekNum = Convert.ToInt32(Console.ReadLine());

            switch(weekNum)
            {
                case 1:
                case 2:
                    Console.WriteLine("Arduino");
                    break;
                case 3:
                case 4:
                case 5:
                    Console.WriteLine("C++");
                    break;
                case 6:
                case 7:
                    Console.WriteLine("Scratch");
                    break;
            }

            // if switch
        }
    }
}

 

[展开全文]
using System;

namespace _016_switch分支语句
{
    class Program
    {
        static void Main(string[] args)
        {
            int number = Convert.ToInt32(Console.ReadLine());

            //if (number == 1)
            //{
            //    Console.WriteLine("矿泉水");
            //}else if(number == 2)
            //{
            //    Console.WriteLine("红茶");
            //}
            //else if (number == 3)
            //{
            //    Console.WriteLine("绿茶");
            //}
            //else if (number == 4)
            //{
            //    Console.WriteLine("雪碧");
            //}
            //else if (number == 5)
            //{
            //    Console.WriteLine("可口可乐");
            //}
            //else
            //{
            //    Console.WriteLine("脉动");
            //}

            switch (number)
            {
                case 1:
                    Console.WriteLine("矿泉水");
                    Console.WriteLine("矿泉水");
                    break;
                case 2:
                    Console.WriteLine("红茶");
                    break;
                case 3:
                    Console.WriteLine("绿茶");
                    break;
                case 4:
                    Console.WriteLine("雪碧");
                    break;
                case 5:
                    Console.WriteLine("可口可乐");
                    break;
                case 6:
                    Console.WriteLine("脉动");
                    break;
                default:
                    Console.WriteLine("没有你要购买的商品");
                    break;
            }
        }
    }
}

 

[展开全文]
            //double res = (3 + 8) / 2.0;
            double res = (3 + 8) * 1.0 / 2;
            //if (4 = age) { }

[展开全文]
using System;

namespace _015_排序_编程题
{
    class Program
    {
        static void Main(string[] args)
        {
            char c = Convert.ToChar(Console.ReadLine());
            // a-z
            if (c >= 'a' && c <= 'z')
            {
                Console.WriteLine("你输入的是一个小写字母");
            }
            else
            {
                Console.WriteLine("你输入的 不是一个小写字母");
            }

            // 0-9  48-57  '0'-'0' '1'-'0'
            if (c >= '0' && c <= '9')
            {
                Console.WriteLine(c - '0');
            }
        }
    }
}

 

[展开全文]
using System;

namespace _015_排序_编程题
{
    class Program
    {
        static void Main(string[] args)
        {
            //int a = Convert.ToInt32(Console.ReadLine());
            //int b = Convert.ToInt32(Console.ReadLine());
            //int c = Convert.ToInt32(Console.ReadLine());

            //// a b    b c    a b
            //if (a > b)
            //{
            //    int temp = a;
            //    a = b;
            //    b = temp;
            //}
            //if (b > c)
            //{
            //    int temp = b;
            //    b = c;
            //    c = temp;
            //}
            //if (a > b)
            //{
            //    int temp = a;
            //    a = b;
            //    b = temp;
            //}
            //Console.WriteLine(a + " " + b + " " + c);


            double m = Convert.ToDouble(Console.ReadLine());
            int k = Convert.ToInt32(Console.ReadLine());
            if (k == 0)
            {
                int temp = (int)m;
                Console.WriteLine(temp);
            }
            else
            {
                // 3.2343 +0.05 = 3.3043 *10 = 33.043 /10 = 3.3
                double temp = ((int)((m + 0.05) * 10)) / 10.0;
                Console.WriteLine(temp);
            }
        }
    }
}

 

[展开全文]
using System;

namespace _014_编程题
{
    class Program
    {
        static void Main(string[] args)
        {
            //int x;
            //x=Convert.ToInt32(Console.ReadLine());//假设输入5
            //if(x--<5) Console.WriteLine(x);
            //else Console.WriteLine(x++);//4


            //int x = 5, a = 0, b = 0;
            //if(x==a+b) Console.WriteLine("****");//小心 if(x=a+b) 编译错误
            //else Console.WriteLine("####");


            //求两个值的较小值
            int a, b;
            a = Convert.ToInt32(Console.ReadLine());
            b = Convert.ToInt32(Console.ReadLine());
            if (a < b)
            {
                Console.WriteLine(a);
            }
            else
            {
                Console.WriteLine(b);
            }


            //int x = 21, y = 1;
            //if (x % 3 == 0 && x % 7 == 0)
            //{
            //    x--;
            //    Console.WriteLine(x);//20
            //}
            //else
            //{
            //    x++;
            //    Console.WriteLine(x);
            //}
        }
    }
}

 

[展开全文]
using System;

namespace _014_编程题
{
    class Program
    {
        static void Main(string[] args)
        {
            char sex = Convert.ToChar(Console.ReadLine());
            int number = Convert.ToInt32(Console.ReadLine());
            if(sex == 'F')
            {
                //Console.WriteLine("800M长跑");
                string project = "800M长跑";
                if(number % 2 == 1)
                {
                    //Console.WriteLine("跳绳");
                    project += " 跳绳";
                }
                else
                {
                    //Console.WriteLine("仰卧起坐");
                    project += " 仰卧起坐";
                }
                Console.WriteLine(project);
            }
            else
            {
                Console.WriteLine("1000M长跑");
                if (number % 2 == 1)
                {
                    Console.WriteLine("跳远");
                }
                else
                {
                    Console.WriteLine("俯卧撑");
                }
            }

            //分支语句只有一行,可以省略{}
            if (true)
                Console.WriteLine("Hello, World!");
            Console.WriteLine("结束");
        }
    }
}

 

[展开全文]

数据类型:

整数int:

 

小数double

 

字符char(单引号):转换为int需强制转换          int a =10;
 char b=(char)a;---- 强制转换

 字符串string(双引号):
输出字符串中有转义符
console.writeline("c:a\b\c\.com")
可在前面加@  并且可以将字符串换行

字符串中想表示引号 可用“”表达‘’

字符串数字相加会组拼:“123”+123
 

[展开全文]
using System;

namespace _014_编程题
{
    class Program
    {
        static void Main(string[] args)
        {
            //int year = Convert.ToInt32(Console.ReadLine());

            //if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
            //{
            //    Console.WriteLine("是闰年");
            //}
            //else
            //{
            //    Console.WriteLine("不是闰年");
            //}


            //int number = Convert.ToInt32(Console.ReadLine());

            //if (number < 0)
            //{
            //    Console.WriteLine(0 - number);
            //}
            //else
            //{
            //    Console.WriteLine(number);
            //}


            //int a = Convert.ToInt32(Console.ReadLine());
            //int b = Convert.ToInt32(Console.ReadLine());
            //int c = Convert.ToInt32(Console.ReadLine());
            //int max = a;
            //if (b > max)
            //{
            //    max = b;
            //}
            //if (c > max)
            //{
            //    max = c;
            //}
            //Console.WriteLine(max * max);


            char a = Convert.ToChar(Console.ReadLine());
            char b = Convert.ToChar(Console.ReadLine());
            if (a > b)
            {
                Console.WriteLine("{0}>{1}", a, b);
            }
            else
            {
                Console.WriteLine("{0}<{1}", a, b);
            }
        }
    }
}

 

[展开全文]
using System;

namespace _013_条件语句_if语句
{
    class Program
    {
        static void Main(string[] args)
        {
            //int x = Convert.ToInt32(Console.ReadLine());
            //int y = Convert.ToInt32(Console.ReadLine());
            //if (x > 0 && y > 0)
            //{
            //    Console.WriteLine("位于第一象限");
            //}else if (x < 0 && y > 0)
            //{
            //    Console.WriteLine("位于第二象限");
            //}
            //else if (x < 0 && y < 0)
            //{
            //    Console.WriteLine("位于第三象限");
            //}
            //else if (x > 0 && y < 0)
            //{
            //    Console.WriteLine("位于第四象限");
            //}else if (0 == x && y != 0)
            //{
            //    Console.WriteLine("位于y轴上");
            //}
            //else if (0 == y && x != 0)
            //{
            //    Console.WriteLine("位于x轴上");
            //}
            //else
            //{
            //    Console.WriteLine("位于原点");
            //}


            int a = Convert.ToInt32(Console.ReadLine());
            int b = Convert.ToInt32(Console.ReadLine());
            int c = Convert.ToInt32(Console.ReadLine());

            if (a + b > c && a + c > b && b + c > a)
            {
                Console.WriteLine("可以组成三角形");
            }
            else
            {
                Console.WriteLine("不可以组成三角形");
            }
        }
    }
}

 

[展开全文]
using System;

namespace _013_条件语句_if语句
{
    class Program
    {
        static void Main(string[] args)
        {
            int score = Convert.ToInt32(Console.ReadLine());

            // if  if else   if else if
            if (score >= 90)
            {
                Console.WriteLine("A");
            }else if (score >= 70)
            {
                Console.WriteLine("B");
            }else if (score >= 60)
            {
                Console.WriteLine("C");
            }
            else
            {
                Console.WriteLine("D");
            }

            //if (score >= 90)
            //{
            //    Console.WriteLine("A");
            //}
            //if (score >= 70 && score <= 89)
            //{
            //    Console.WriteLine("B");
            //}
            //if (score >= 60 && score <= 69)
            //{
            //    Console.WriteLine("C");
            //}
            //if (score < 60)
            //{
            //    Console.WriteLine("D");
            //}
        }
    }
}

 

[展开全文]
using System;

namespace _013_条件语句_if语句
{
    class Program
    {
        static void Main(string[] args)
        {
            //int number = Convert.ToInt32(Console.ReadLine());
            ////
            //if (number % 2 == 1)
            //{
            //    Console.WriteLine("奇数");
            //}
            //else
            //{
            //    Console.WriteLine("偶数");
            //}


            int age = Convert.ToInt32(Console.ReadLine());

            //if (age >= 18 && age <= 30 && age % 2 == 1)
            //{
            //    Console.WriteLine("可以获得奖品");
            //}

            if (age >= 18 && age <= 30)
            {
                Console.WriteLine("可以参加获得");
                if (age % 2 == 1)
                {
                    Console.WriteLine("获得奖品");
                }
                else
                {
                    Console.WriteLine("没有获得奖品");
                }
            }
            else
            {
                Console.WriteLine("不可以参加获得");
            }
        }
    }
}

 

[展开全文]
using System;

namespace _013_条件语句_if语句
{
    class Program
    {
        static void Main(string[] args)
        {
            int age = Convert.ToInt32(Console.ReadLine());

            //if语句
            if (age <= 16)
            {
                //当满足条件的时候会执行
                Console.WriteLine("可以进入");
            }
            else
            {
                Console.WriteLine("年龄太大,不可以进");
            }
            // if(){}        if(){}else{}

            Console.WriteLine("程序结束");
        }
    }
}

 

[展开全文]
using System;

namespace _010_编程题
{
    class Program
    {
        static void Main(string[] args)
        {
            //// 123
            //// 123/100
            //int number = Convert.ToInt32(Console.ReadLine());

            //int ge = number % 10;
            //int shi = (number / 10) % 10;
            //int bai = number / 100;
            //Console.WriteLine("" + ge + shi + bai);

            //// 23452
            //int number = Convert.ToInt32(Console.ReadLine());
            //int shi = (number / 10) % 10;
            //int qian = (number / 1000) % 10;
            //int numberNew = qian * 10 + shi;
            //char c = (char)numberNew;
            //Console.WriteLine(c);

            //int a = 3;
            //int b = a++ + a++;
            //// 3 + a++ //a=4
            //// 3 + 4 //a=5
            //Console.WriteLine(b);
            //Console.WriteLine(a);

            //int a = 3;
            //int b = a++ + (++a);
            //// 3 + (++a)  //a=4
            //// 3 + 5  //a=5
            //Console.WriteLine(b);
            //Console.WriteLine(a);

            int mathScore=Convert.ToInt32(Console.ReadLine());
            int englishScore=Convert.ToInt32(Console.ReadLine());
            bool isGetAward = mathScore >= 90 && englishScore >= 90;
            Console.WriteLine(isGetAward);
        }
    }
}

 

[展开全文]
using System;

namespace _011_运算符的优先级
{
    class Program
    {
        static void Main(string[] args)
        {
            int res = (3 + 2) * 4;

            Console.WriteLine(res);//20
        }
    }
}

 

[展开全文]

授课教师

SiKi学院老师

课程特色

下载资料(1)
视频(118)
图文(1)