#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
long fac(int n){
if (n < 0){
printf("n<0,date error!");
return 0;
}
else if (n == 0 || n == 1)
return 1;
else
return(fac(n - 1)*n);
}
int main(){
int n;
long y;
printf("n=");
scanf("%d", &n);
y = fac(n);
printf("\n,%d!=%ld", n, y);
system("pause");
return 0;
}
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
int Fact(int a){
int y;
for (y = 1; a > 0; a--)
y = y*a;
return y;
}
int require(int n, int m){
int z;
z=Fact(n)/(Fact(m)*Fact(n - m));
return z;
}
int main(){
int x=10, y=6;
int result;
result = require(x, y);
printf("\nresult=%d", result);
system("pause");
}
#define _CRT_SECURE_NO_WARNINGS//计算阶乘
#include<stdio.h>
#include<stdlib.h>
int Factorial(int a){
int i ; int y = 1;
for (y = 1; a> 0;a--)
y= y*a;
return y;
}
int main(){
int b;
int result;
printf("请输入一个数字:");
scanf("%d", &b);
int Factorial(int b);
result = Factorial( b);
printf("%d\n", result);
system("pause");
return 0;
}
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
float suv(float x, float y){
printf("%f%f", x, y);
return(x - y);
}
int main(){
float suv(float, float);
float x1, x2, x3;
printf("input x1,x2:");
scanf("%f%f", &x1, &x2);
x3 = suv(x1, x2);
printf("\nsuv=%6.2f", x3);
system("pause");
return 0;
}
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main(){
int a = 2, b = 3, i = 3, j = 2;
double c;
c = pow(a, i) + pow(b, j);
printf("c=%f", c);
system("pause");
return 0;
}
#include<stdio.h>
#include<stdlib.h>
int max( int x, y, z){
int tmp;
tmp = x;
if (y > tmp)
tmp = y;
if (z > tmp);
tmp = z;
return tmp;
}
int main(){
int a, b, c;
int max_value;
printf("请输入三个数字:");
scanf("%d%d%d", &a, &b, &c);
max_value = max(a, b, c);
printf("%d\n", max_value);
system("pause");
return 0;
}