tinh giai thua trong c
hj,
đây là đoạn code đơn zản nhất, nếu bạn muốn viết bằng hàm hoặc đệ quy thì pm típ nhá^^
code:
#include "stdio.h"
#include "conio.h"
#include "math.h"
void main(){
int s=1;
printf("nhap vao so can tinh giai thua:");
scanf("%d",&n);
if(n==1||n==0)
printf("ket wa: 1");
else{
for(int i=1;i<=n;i++){
s*=i;
}
printf("
ket wa: %d",s);
}
getch();
}
nick:philong_thangthien16
blog: http://blog8x.tk
Bạn đang đọc truyện trên: truyentop.pro