#include<stdio.h> int add(int a,int b); int minus(int a,int b); int multip(int a,int b); int quotient(int a,int b); int mod(int a,int b); int main() { int a,b; printf("请输入两个数字"); scanf("%d%d",&a,&b); printf("这两个数字的和为%d\n",add(a,b)); printf("这两个数字的差为%d\n",minus(a,b)); printf("这两个数字的积为%d\n",multip(a,b)); printf("这两个数字的商为%d\n",quotient(a,b)); printf("这两个数字的模为%d\n",mod(a,b)); return 0; } int add(int a,int b) { int c; c=a+b; return c; } int minus(int a,int b) { int c; c=a-b; return c; } int multip(int a,int b) { int c; c=a*b; return c; } int quotient(int a,int b) { int c; c=a/b; return c; } int mod(int a,int b) { int c; c=a%b; return c; }
#include<stdio.h> int prime(int); int main() { int a; int sushu; printf("请输入一个数字"); scanf("%d",&a); sushu=prime(a); printf("%d是一个质数吗?\n%d(1是质数,0不是质数)",sushu); return 0; } int prime(int a) { int c; int n; for(n=1,c=2;c<a;c++) { if(a%c==0) n=0; break; if(a%c!=0) continue; } return n; }
#include<stdio.h> int max2(int a,int b); int max4(int a,int b,int c,int d); int main() { int a,b; int c,d; int i; scanf("%d%d",&a,&b); scanf("%d%d",&c,&d); i=max4(a,b,c,d); printf("最大的数字是%d",i); return 0; } int max2(int a,int b) { int c; c=(a>b)?a:b; return c; } int max4(int a,int b,int c,int d) { int f,g,h; f=max2(a,b); g=max2(c,d); h=max2(f,g); return h; }