Console.WriteLine ("一到一百不能被七整出的数是:");
int[] a = new int[100];
int c = 1;
int sum = 0;
for (int i = 1; i < 101; i++)
{
if (i % 7 != 0)
{
a[c] = i;
c++;
}
}
for (int b = 1; b < c; b++)
{
Console.Write(a[b]+"\t") ;
if(b%4==0)
{
Console .Write ("\n");
}
}
for (int d = 0; d < c; d++)
{
sum = sum + a[d];
}
Console.WriteLine("\n" + "和为:{0}", sum);
Console.ReadKey();
网友评论