求1+2+3+...+n,要求不能使用乘除法、for、while、if、else、switch、case等关键字及条件判断语句(A?B:C)。
题目:
求1+2+3+…+n,要求不能使用乘除法、for、while、if、else、switch、case等关键字及条件判断语句(A?B:C)。
使用语言:c语言 环境:Visual studio
源代码:
#include <stdio.h>
unsigned int factorial(int n)//递归函数
{
int ans = n;
ans && (ans += factorial(n - 1));//短路语句
原创
2021-03-21 23:56:43 ·
72 阅读 ·
0 评论