用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

上一篇:Tyvj P1813 [JSOI2008]海战训练


下一篇:Windows+Linux----打造和谐的开发环境