标签:images col static linq ima for ati ... ext
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace _1._1 { class Program { static void Main(string[] args) { int n, i, result = 0; //定义变量 Console.WriteLine("请输入一个正整数"); n = int.Parse(Console.ReadLine()); //输入整数n if (n % 2 == 0) //判断n奇偶性 i = 2; else i = 1; for (; i <= n; i += 2) //计算i+(i+2)+(i+2+2)+....+n result += i; Console.WriteLine(result); Console.WriteLine("按回车键结束"); Console.ReadLine(); } } }
标签:images col static linq ima for ati ... ext
原文地址:http://www.cnblogs.com/xx--/p/7588992.html