实验五
#include<stdio.h>
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;
}
int main()
{
int x,y;
scanf("%d %d",&x,&y);
printf("%d\n",add(x,y));
printf("%d\n",minus(x,y));
printf("%d\n",multip(x,y));
printf("%d\n",quotient(x,y));
printf("%d",mod(x,y));
return 0;
}
#include<stdio.h>
int prime(int n)
{
int i;
for(i=2;i<=n;i++)
{
if(n%i==0&&n==i)
{
return 1;
}
else
{
return 0;
}
}
}
int main()
{
int x;
scanf("%d",&x);
printf("%d\n",prime(x));
return 0;
}
#include<stdio.h>
int max2(int a,int b)
{
if(a>b)
{
return a;
}
else
{
return b;
}
}
int max4(int a,int b,int c,int d)
{
int x,y,z;
x=max2(a,b);
y=max2(c,d);
z=max2(x,y);
return z;
}
int main()
{
int a1,a2,a3,a4;
scanf("%d %d %d %d",&a1,&a2,&a3,&a4);
printf("%d\n",max4(a1,a2,a3,a4));
return 0;
}