namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("1~100中所有不能被7整除的数有:");
int sum=0;
int num = 0;
for(int i=1;i<=100;i++)
{
if(i % 7!=0)
{
sum += i;
num++;
Console.Write(i + "\t");
}
if (num == 4)
{
Console.WriteLine();
num = 0;
}
}
Console.WriteLine("");
Console.WriteLine ("数据之和为{0}",sum);
Console.ReadKey();
}
}
}
网友评论