1 namespace test1 2 { 3 class Program 4 { 5 //求出1~1000之间的所有能被7整除的数,并计算和输出每5个的和 6 static void Main(string[] args) 7 { 8 int sum = 0, t = 0, h = 0; 9 for (int i = 1; i < 1000; i++) 10 { 11 if (i % 7 == 0) 12 { 13 t += 1; 14 sum += i; 15 if (t == 5) 16 { 17 Console.Write("{0,-5} ", sum); 18 sum = 0; 19 t = 0; 20 h += 1; 21 if (h % 5 == 0) 22 Console.WriteLine(); 23 24 25 } 26 } 27 } 28 Console.ReadKey(); 29 } 30 } 31 }