using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication3 { class Program { static void Main(string[] args) { int n = 0, sum=1; do { sum += n; n++; } while (n <= 100); Console.WriteLine("n:{0}自然数之和为:{1}", n,sum); Console.Read(); } } }
时间: 2024-10-12 16:00:31