test1-1

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SECOND_C
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("请输入一个正整数");
int n =Convert.ToInt32( Console.ReadLine());
int sum = 0;
if(n%2!=0)
for(int i=1;i<=n;i+=2)
{
sum += i;
}
else
for(int j=0;j<=n;j+=2)
{
sum+=j;
}
Console.WriteLine(sum);
}
}
}

posted on 2017-09-11 21:08  YuJiaJia  阅读(176)  评论(0编辑  收藏  举报

导航