用if else 判断是不是7的倍数等

static void Main(string[] args)
        {
            while (true)
            {
                int b;
                Console.WriteLine("请输入一个100以内的整数:");
                b =Convert.ToInt32( Console.ReadLine());
                if (b % 7 == 0)
                {
                    Console.WriteLine(b+"是7的倍数");

                }
                else
                {
                    Console.WriteLine(b + "不是7的倍数");
                }

                if (b / 10 == 7)
                {
                    Console.WriteLine(b + "十位数为7");
                }
                else
                {
                    Console.WriteLine(b + "十位数不为7");
                }
                if (b % 10 == 7)
                {

                    Console.WriteLine(b + "个位数为7");

                }
                else
                {
                    Console.WriteLine(b + "个位数不为7");

                }

                Console.ReadLine();
            }
        }
    }
}    //进行三次判断,即先判断是不是7的倍数,然后分而判断个位十位是不是7

posted @ 2015-03-27 14:13  XCml  阅读(644)  评论(0编辑  收藏  举报