namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int a = 1;
int count = 0;
while (a<=100) //while就相当于把for拆开
{
if (a/10==7||a%10==7||a%7==0)
{
Console .Write(a+"\t");
count++; //此处是计算跟7有关的数字的累加
}
a++; //自加放在if外 每一次自加后判断是否符合初始条件 在进入if
}
Console.WriteLine ("共有" + count + "个跟7有关的数");
Thread.Sleep(2000);
}
}
}