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

时间:2021-01-29 20:09:31

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