我的第17个代码

2021-02-20 13:30发布

我的第十七个代码

#define _CRT_SECURE_NO_WARNINGS 1

#include<stdio.h>

int main()
{
int a = 1;
int b = 1;
int n = 1;
scanf("%d", &n);
while (a <= n)
{
b = a*b;
a++;
}
printf("%d\n", b);

    return 0;

}//利用while循环计算n的阶乘

int main()
{

int a = 1;
int b = 1;
int n = 1;
scanf("%d", &n);
for (a = 1; a <= n; a++)
{
    b = a*b;

}
printf("%d\n", b);
return 0;

};//利用for循环计算n的阶乘

int main()
{
int a = 1;
int b = 1;
int n = 1;
scanf("%d",& n);
do
{
b = a*b;
a++;
}
while (a <= n);
printf("%d\n", b);
return 0;
}//利用do……while循环计算n的阶乘

标签: