标签:turn adk str write i++ ring key 题目 static
5,一球从100米高度自由落下,每次落地后反跳回原高度的一半;再落下,求它在第10次落地时,共经过多少米?第10次反弹多高?
float height = 100; float distance = 0; for (int i = 1; i <= 10; i++) { distance += height; height /= 2; } Console.WriteLine("经过了" + distance + "米,第10次反弹" + height / 2 + "米"); Console.ReadKey();
6,题目:求1+2!+3!+...+20!的和?
static int Factorial(int n) { int res = 1; for (int i = 1; i <= n; i++) { res *= i; } return res; } static void Main(string[] args) { int sum = 0; for (int i = 1; i <= 20; i++) { sum += Factorial(i); } Console.WriteLine(sum); Console.ReadKey(); }
标签:turn adk str write i++ ring key 题目 static
原文地址:https://www.cnblogs.com/wuxiaohui1983/p/9973213.html