算法题1+2+...+N

it2022-05-05  171

题目:求1+2+…+n,要求不能使用乘除法、forwhileifelseswitchcase等关键字以及条件判断语句(A?B:C)。

int solve(int n) { int i = 1; (n > 1) && (i = solve(n - 1) + n); return i; }

转载于:https://www.cnblogs.com/jasonkent27/p/4098457.html

相关资源:计算机算法设计与分析期末考试复习题.doc

最新回复(0)