C#基础04

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Base04
{
    class Program
    {
        static void Main(string[] args)
        {
            //Console.WriteLine("请输入一个数字:");
            //int index = Int32.Parse(Console.ReadLine());
            //if (输入的永远是比较运算符)
            //if(bool型) 当条件满足时执行当前代码块  else 当条件不满足时执行当前代码块
            //if (index > 0)
            //{
            //    Console.WriteLine("输入的数字大于0");
            //}
            //else
            //{
            //    Console.WriteLine("输入的数字小于或等于0");
            //}

            //多重
            //Console.WriteLine("请输入一个数字:");
            //int index = Int32.Parse(Console.ReadLine());
            //if(判断的第一个条件) 如果满足第一个条件则后续的所有的代码块不执行  
            //else if(判断的第N个条件)  可以出现N次,满足条件则其余的判断则不会执行
            //else 完全不满足当前的 if 和 else if 里面的所有的条件判断
            //if (index > 0)
            //{
            //    Console.WriteLine("输入的数字大于0");
            //}
            //else if (index == 0)
            //{
            //    Console.WriteLine("输入的数字等于0");
            //}
            //else
            //{
            //    Console.WriteLine("输入的数字小于0");
            //}

            //嵌套if
            //Console.WriteLine("1代表经济舱,2代表头等舱");
            //int index = Int32.Parse(Console.ReadLine());
            //if (index == 1)
            //{
            //    Console.WriteLine("请输入月份!");
            //    int m = Int32.Parse(Console.ReadLine());
            //    if (m<11&&m>4)
            //    {
            //        Console.WriteLine("经济舱+旺季");
            //    }
            //    else
            //    {
            //        Console.WriteLine("经济舱+淡季");
            //    }
            //}
            //else
            //{
            //    Console.WriteLine("请输入月份!");
            //    int m = Int32.Parse(Console.ReadLine());
            //    if (m < 11 && m > 4)
            //    {
            //        Console.WriteLine("头等舱+旺季");
            //    }
            //    else
            //    {
            //        Console.WriteLine("头等舱+淡季");
            //    }
            //}

            //Console.WriteLine("请输入月份");
            //int m = Int32.Parse(Console.ReadLine());
            //switch (m)
            //{
            //    case 1:
            //    case 2:
            //    case 3:
            //    case 4:
            //    case 5:
            //    case 6:
            //    case 7:
            //    case 8:
            //    case 9:
            //    case 10:
            //    case 11:
            //    case 12:
            //        Console.WriteLine("当前得到月份是{0}",m+"月");
            //        break;
            //    default:
            //        Console.WriteLine("错误");
            //        break;
            //}

            //死循环
            //循环的条件 的值 也是bool类型 条件成立则执行循环体  条件不成立则退出
            //while 先判断 后执行  偏高  朱行读取
            //while (true)
            //{
            //    Console.WriteLine("1");
            //}
            //int index = 1;
            //while (index<10)
            //{
            //    Console.WriteLine(index);
            //    index++;
            //}
            //do.....while(循环条件); 先执行 后判断  无
            //do
            //{
            //    Console.WriteLine("1");
            //} while (true);

            //int index = 0;
            //do
            //{
            //    index++;
            //    Console.WriteLine(index);
            //} while (index <10);

            //for(开始的位置:判断的条件:叠加(++)或者递减(--))
            //for (::)
            //{
            //    Console.WriteLine("1");
            //}
            //第一次执行的时候,是不进入叠加或者递减
            //第二次开始
            //for (int index = 0; index < 10; index++)
            //{
            //    Console.WriteLine(index);
            //}

            //for (int i = 0; i < 11; i++)
            //{
            //    if (i == 4)
            //    {
            //        break;//退出循环
            //    }
            //    Console.WriteLine(i);
            //}

            //for (int i = 0; i < 11; i++)
            //{
            //    if (i == 4)
            //    {
            //        //continue;//退出当前循环
            //        return;//返回到循环外
            //    }
            //    Console.WriteLine(i);
            //}



            //1.小强参加Java考试,爸爸答应他如下条件:(多重if)
            //    成绩 >= 90 :送奔驰轿车

            //    成绩 >= 80 :送奥迪轿车

            //    成绩 >= 60 :送比亚迪F0

            //    成绩 < 60  :送一个耳光
            //Console.WriteLine("请输入小强Java考试成绩");
            //int value = Int32.Parse(Console.ReadLine());
            //if (value >= 90)
            //{
            //    Console.WriteLine("送奔驰轿车");
            //}
            //else if (value>=80)
            //{
            //    Console.WriteLine("送奥迪轿车");
            //}
            //else if (value >= 80)
            //{
            //    Console.WriteLine("送比亚迪F0");
            //}
            //else
            //{
            //    Console.WriteLine("送一个耳光");
            //}

            //2.机票预定:实际机票价格 原价为4000元(嵌套if)
            //    5 - 10月为旺季,头等舱打9折,经济舱打7.5折
            //    其余时间为淡季,头等舱打6折,经济舱打3折
            //Console.WriteLine("1代表经济舱,2代表头等舱");
            //int n = Int32.Parse(Console.ReadLine());
            double n = Convert.ToDouble(Console.ReadLine());
            //if (n == 1)
            //{
            //    Console.WriteLine("请输入月份!");
            //    int m = Int32.Parse(Console.ReadLine());
            //    if (m < 11 && m > 4)
            //    {
            //        Console.WriteLine("经济舱+旺季(票价为):"+4000*0.75);
            //    }
            //    else
            //    {
            //        Console.WriteLine("经济舱+淡季(票价为):" + 4000 * 0.3);
            //    }
            //}
            //else
            //{
            //    Console.WriteLine("请输入月份!");
            //    int m = Int32.Parse(Console.ReadLine());
            //    if (m < 11 && m > 4)
            //    {
            //        Console.WriteLine("头等舱+旺季(票价为):" + 4000 * 0.9);
            //    }
            //    else
            //    {
            //        Console.WriteLine("头等舱+淡季(票价为):" + 4000 * 0.6);
            //    }
            //}

            //3.输入一个月份, 打印出该月的天数(switch)
            //  月份: 4,6,9,11 小月 1,3,5,7,8,10,12 大月
            //Console.WriteLine("请输入月份");
            //int m = Int32.Parse(Console.ReadLine());
            //switch (m)
            //{

            //    case 4:
            //    case 6:
            //    case 9:
            //    case 11:
            //        Console.WriteLine("当前得到月份是小月{0}", m + "月"+"天数为:30天");
            //        break;
            //    case 1:
            //    case 2:
            //    case 3:
            //    case 5:
            //    case 7:
            //    case 8:
            //    case 10:
            //    case 12:
            //        Console.WriteLine("当前得到月份是大月{0}", m + "月"+"天数为:31天");
            //        break;

            //    default:
            //        Console.WriteLine("错误");
            //        break;
            //}

            //4.循环输出10到100之间所有能被5整除的数(while)。
            //int index = 9;
            //while (index<101)
            //{
            //    index++;
            //    if (index%5==0)
            //    {
            //        Console.WriteLine(index);

            //    }
            //}

            //5.计算1 + 2 + 3 +……+100的结果(do...while)
            //int i = 1;
            //int count = 0;
            //do
            //{
            //    count = i + count;
            //    i++;
            //} while (i <=100);
            //{
            //    Console.WriteLine(count);
            //}
            //6.从1一直加到100,但如果累加的和大于500也要结束循环,并输出此时已经加到的数是什么(for)
            //int count = 0;
            //for (int i = 1; i <= 100; i++)
            //{
            //    count = i + count;
            //    if (count >= 500)
            //    {
            //        Console.WriteLine(i);
            //        break;
            //    }
            //}




            //  Console.ReadKey();
        }
    }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值