2018-12-26

2018-12-26  本文已影响0人  晨颜
        Console.WriteLine("1-100不能被7整除的数据为:");
        int n = 0; int sum = 0;
        for (int i = 1; i <= 100; i++)
        {
            if (i % 7 != 0)
            {
                Console.Write(i + "\t");
                n++;
                sum += i;
                if (n % 4 == 0)
               {
                    Console.WriteLine();
                }
            }
        }
        Console.WriteLine();
        Console.Write("数据之和为{0}", sum);
        Console.ReadKey();
image.png
        Console.WriteLine("请输入你的密码:");
        string mima = "111111";
        int amount = 0;
        int count = 0;
        for (count = 0; count < 3; count++)
        {
            string shuru = Console.ReadLine();
            if (shuru != mima)
            {
                Console.WriteLine("你输入的密码有误,重新输入。");
                continue;
            }
            else
            {
                Console.WriteLine("请输入金额");
                amount = Convert.ToInt32(Console.ReadLine());
                break;
            }
        }
        for (int i = 0; i < 3; i++)
        {
            if (amount < 0 | amount > 1000 | amount % 100 != 0)
            {
                Console.WriteLine("你输入的不合法,请重新输入");
                amount = Convert.ToInt32(Console.ReadLine());
                continue;
            }
            else
            {
                Console.WriteLine("您取了{0}块钱", amount);
                Console.WriteLine("\n" + "交易完成");
                break;
            }

        }
        Console.ReadKey();
image.png
上一篇 下一篇

猜你喜欢

热点阅读