#include<stdio.h>
int main()
{
int m,n;
double s,result;
double fact(int x);
printf("Enter m and n:");
scanf("%d%d",&m,&n);
s=fact(m-n);
result=fact(m)/(fact(n)*s);
printf("result=%.0f
",result);
return 0;
}
double fact(int x)
{
int i;
double result;
result=1;
for(i=1;i<=x;i++)
result=result*i;
return result;
}
#include<stdio.h> #include<math.h> int main(void) { int count,m,x,y; int isprime(int m); printf("Enter x and y (x<y):"); scanf("%d%d",&x,&y); count=0; for(m=2;((x<=m)||(m<=y));m++){ if(isprime(m)!=0){ printf("%6d",m); count++; if(count%10==0) printf(" "); } } printf("count=%.0f ",count); return 0; } int isprime(int m) { int i,n,x,y; if(m==1)return 0; n=sqrt(m); for(i=2;((x<=i)||(i<=y));i++) if(m%i==0){ return 0; } return 1; }
#include<stdio.h> double fact(int n);//定义函数fact int main(void) { int i; double sum; sum=0; for(i=1;i<=100;i++)//for循环实现递增 sum=sum+fact(i); printf("1!+2!+...+100!=%e ",sum); return 0; } double fact(int n)//函数fact的内容 { int i; double result; result=1; for(i=1;i<=n;i++) result=result*i; return result; }