首页 > 其他分享 >给出数n的阶乘

给出数n的阶乘

时间:2023-02-26 12:32:01浏览次数:41  
标签:int sum ++ 给出 includeint printf 阶乘

#include<stdio.h>

int main() {
int n = 0;
int sum = 1;
printf("请输入一个正整数:");
scanf_s("%d", &n);
for (int i = 1; i < n+1; i++) {
sum = i * sum;
}
printf("%d的阶乘是:%d", n, sum);
return 0;
}


标签:int,sum,++,给出,includeint,printf,阶乘
From: https://blog.51cto.com/u_13606048/6086329

相关文章