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

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

价格 免费
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
        }
    }
}

 

[展开全文]
using System;

namespace _010_逻辑运算符
{
    class Program
    {
        static void Main(string[] args)
        {
            // &&和    ||或    !非
            //bool a = (3 < 4) && (9 < 10);// true && true
            bool a = true && true;

            bool b = (3 < 2) || (9 < 7);

            //bool c = !(4 < 7);
            bool c = !true;//取反

            Console.WriteLine(a);
            Console.WriteLine(b);
            Console.WriteLine(c);
        }
    }
}

 

[展开全文]
using System;

namespace _009_关系运算符和布尔类型
{
    class Program
    {
        static void Main(string[] args)
        {
            //    bool a = true;//是的  真的  满足条件  1
            //    bool b = false;//不是  假的  不满足条件  0
            //    Console.WriteLine(a);//Ctrl+D 快速复制一行代码
            //    Console.WriteLine(b);

            bool a = 45 == 67;
            bool b = 45 < 67;
            bool c = 45 <= 67;
            bool d = 45 > 67;
            bool e = 45 >= 67;
            bool f = 45 != 67;

            Console.WriteLine(a);//False
            Console.WriteLine(b);//True
            Console.WriteLine(c);//True
            Console.WriteLine(d);//False
            Console.WriteLine(e);//False
            Console.WriteLine(f);//True
        }
    }
}

 

[展开全文]
using System;

namespace _008_自增自减运算符
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = 5;
            //a++;//a=a+1;
            //++a;//
            //int b = a++;//a++先赋值再自增    ++a先自增再赋值
            //int b = ++a;
            //Console.WriteLine(a + ":" + b);

            Console.WriteLine(a++);
            Console.WriteLine(a);
        }
    }
}

 

[展开全文]
using System;

namespace _007_数学运算符
{
    class Program
    {
        static void Main(string[] args)
        {
            //int num = 39;
            //int ge = num % 10;
            //int shi = num / 10;
            //Console.WriteLine("个位是{0},十位数是{1}", ge, shi);

            //int a = 0;
            //a + 1;
            //Console.WriteLine(a);

            //int a = 0;
            //a = a + 1;
            //Console.WriteLine(a);//1

            int a = 0;
            a += 10;//a=a+10;
            Console.WriteLine(a);
            a -= 5;//5;
            Console.WriteLine(a);
            a *= 3;//15
            Console.WriteLine(a);
            a /= 6;//2
            Console.WriteLine(a);
            a %= 2;//0
            Console.WriteLine(a);
        }
    }
}

 

[展开全文]

c# 代码会被编译成 exe 和 dll 程序集,而不是直接就被编译成二进制文件。当程序集运行的时候 会被及时的编译成二进制文件 供电脑执行。

 

为什么需要这多一步呢?

老师说程序集是跑在 .net框架环境里面。多这一步是为了方便开发者能够使用到 net框架自带的一些东东。。。

[展开全文]
using System;

namespace _007_数学运算符
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = 23 + 23;
            int b = 2 - 10;
            int c = 4 * 23;
            int d = 45 / 10;
            int e = 45 % 10;

            double f = 45 / 10.0;

            Console.WriteLine(a);
            Console.WriteLine(b);
            Console.WriteLine(c);
            Console.WriteLine(d);
            Console.WriteLine(e);
            Console.WriteLine(f);
        }
    }
}

 

[展开全文]
using System;

namespace _006_变量研究
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = 23, b = 45;
            // 23+45=68
            //Console.WriteLine(a + "+" + b + "=" + (a + b));
            Console.WriteLine("{0}+{1}={2}", a, b, a + b);//0 1 2

            Console.WriteLine("两个数字相加{0}+{0}={2}",34,123,4);

            //Console.WriteLine("两个数字相加{0}+{0}={3}",34,123,4);//不存在{3}报错
        }
    }
}

 

[展开全文]
using System;

namespace _006_变量研究
{
    class Program
    {
        static void Main(string[] args)
        {
            //int class namespace string void

            int age;
            int myAge;
            int xiaomingAge;
            double enemyHp;
            double PI;
            int HP;
            int MP;
        }
    }
}

变量驼峰命名;

方法和类名Pascal命名。

[展开全文]

授课教师

加我的QQ问问题:804632564

课程特色

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