阶乘的算法

#include<stdio.h>
int main()
{
	int n;
	scanf("%d",&n);
	int face=1;
	int i=1;
while(i<=n){
	face*=i;
	i++;
	}
printf("%d!=%d\n",n,face);
}

  n=1*2*3*4……
         n!=?

 

#include <stdio.h>
int main()
{
    int i,n;
    double sum=1;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
        sum=sum*i;
    printf("%d!=%lf",n,sum);
    printf("\n");
    return 0;
}

  for循环深入理解:

#include<stdio.h>
int main()
{
int i;
for(i=0;i<5;i++){
    printf("i=%d ",i);
    }
return 0;
}

 

posted @ 2022-11-02 11:19  飞雪飘鸿  阅读(118)  评论(0编辑  收藏  举报
https://damo.alibaba.com/ https://tianchi.aliyun.com/course?spm=5176.21206777.J_3941670930.5.87dc17c9BZNvLL