using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _02求奇偶数和
{
class Program
{
static void Main(string[] args)
{
//计算1-100之间所有奇偶数的和
int Even_Sum = 0;
int Odd_Sum = 0;
for (int i = 1; i <= 100; i++)
{
if (i % 2 == 0)
{
Even_Sum+= i;
}
else
{
Odd_Sum+= i;
}
}
Console.WriteLine("1-100之间所有的偶数的和为:{0},奇数和为:{1}",Even_Sum,Odd_Sum);
Console.ReadKey();
}
}
}
_02求奇偶数和
最新推荐文章于 2024-07-15 23:36:27 发布