这段代码是答应正三角形 ,中途出了一个问题 将temp-- 写成了 temp = n--; 这样n也在减 ,因此得到的结果就是错误的 void PrintStar() { printf("please input the n:"); int n; scanf("%d",&n); int sum = 2*n +1; int temp = n ; int location; for(int i = 0;i< n;i ++) { location = 0; temp --; while(location < temp) { printf(" "); location ++; } for(int j = 0;j< 2*i+1;j++) printf("*"); printf("/n"); } } 采用非阶乘求1!+2!+。。。。+n!的结果 采用迭代法来求解,迭代法就是f1 = f(f0); void GetOrder() { double foreSingleSum = 1; double laterSingleSum = foreSingleSum; double sum = 0; printf("please input the n:"); int n;int i = 1; scanf("%d",&n); do { sum += laterSingleSum; laterSingleSum = (++i) * foreSingleSum; foreSingleSum = laterSingleSum; } while(i <= n); printf("%lf",sum); }