我是靠谱客的博主 多情啤酒,最近开发中收集的这篇文章主要介绍C# 判断和循环,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

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

namespace _0903_判断和循环
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("9月3日表示A生日");
            Console.WriteLine("9月17日表示B生日");
            Console.WriteLine("9月18日表示c生日");
            Console.WriteLine("9月20日表示d生日");
            Console.WriteLine("9月25日表示e生日");
            Console.WriteLine("9月28日表示f生日");
            Console.WriteLine("n" + "请选择要查看的人的名字:");
            string s = Console.ReadLine();
            Console.WriteLine("输入的时期是:9月{0}日" + "n", s);
            int n = Convert.ToInt32(s);
            if (n <= 0 || n > 30)
            {
                Console.WriteLine("您输入错误");

                }else
                {
                //    //if (n == 3)
                //    //{
                //    //    Console.WriteLine("a");

                //    //}
                //    //if (n == 17)
                //    //{
                //    //    Console.WriteLine("b");

                //    //}
                //    //  if (n==18)
                //    //{
                //    //    Console.WriteLine("c");
                //    //}
                //    //  if (n==20)
                //    //{
                //    //    Console.WriteLine("d");
                //    //}
                //    //  if(n==25)
                //    //{
                //    //    Console.WriteLine("e");
                //    //}
                //    //  if(n==28)
                //    //{
                //    //    Console.WriteLine("f");
                //    //}
                //    //else
                //    //{
                //    //    Console.WriteLine("没人过生日");
                //    //}
                //   /*
                //    //判断语句第二种 switch  分支判断
                //    //有括号的,case
                //    //if(布尔值)
                //    //switch(字符串/整型)
                //    // {
                //    //   case 满足的值:要执行的操作;break;
                //    default:要执行的操作;break;
                //   多个case同时存在!
                //   但是!default只能有一个;
                //   // }
                //   break;指结束当前判断,返回上一层



                //     */
                //    switch ( s)
                //    {
                //        case "A":
                //            Console.WriteLine("9月3日 表示{0}生日", s);
                //            break;
                //        case "B":
                //            Console.WriteLine("9月17日 表示{0}生日", s);
                //            break;
                //        case "C":
                //            Console.WriteLine("9月18日 表示{0}生日", s);
                //            break;
                //        case "D":
                //            Console.WriteLine("9月20日 表示{0}生日", s);
                //            break;
                //        case "E":
                //            Console.WriteLine("9月25日 表示{0}生日", s);
                //            break;
                //        case "F":

                //            Console.WriteLine("9月28日 表示{0}生日", s);
                //            break;
                //        default:
                //            Console.WriteLine("没人过生日", s);
                //            break;
                //    }

                }

                /*
                循环分为两种:
                for(起始变量(循环次数);判断条件;操作)
                注意死循环:特征不停的循环
                原因:条件恒为真
                */

                Console.WriteLine("倒计时 开始");
                for (int i = 1; i <= 12; i++)
                {
                    for (int j = 1; j <= 12; j++)
                    {
                        Console.Write("{0}*{1}={2}" + "t", i, j, (i * j));
                    }
                }
                Console.ReadLine();
            }
        }
    }
}

 

最后

以上就是多情啤酒为你收集整理的C# 判断和循环的全部内容,希望文章能够帮你解决C# 判断和循环所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(70)

评论列表共有 0 条评论

立即
投稿
返回
顶部