//求5!
//1种方法。
#include<stdio.h>
int main(){
int t=1,i=2;
while(i<=5){
t=t*i;
i++;
}
printf("5! is %d\n%d\n",t,i);
return 0;
}
//2种方法。
#include"stdio.h"
void main(){
int t=1,i=2;
do{
t=t*i;
i++;
}while(i<=5);
printf("5! is %d",t);
}
//3种方法。
#include<stdio.h>
void main(){
int t=1,i;
for( i=2;i<=5;i++){
t=t*i;
}
printf("5! is %d\n",t);
}