输入一个正整数n,若n为奇数,程序计算出数列1+3+5....+n;若n为偶数,则计算出2+4+6....+n之和
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication7
{
class Program
{
static void Main(string[] args)
{
int x = int.Parse( Console.ReadLine());
int y = 0;
for (int i = x; i > 0; i -= 2)
{
y += i;
}
Console.WriteLine(y);
Console.Read();
}
}
}