1、
main()
{float x,y,z,m;
scanf("%f,%f,%f",&x,&y,&z);
if(x>y&&x>z) m=x;
if(y>x&&y>z) m=y;
if(z>x&&z>y) m=z;
printf("%f",m);
}
2、
main()
{float x,y,z,m;
scanf("%f,%f,%f",&x,&y,&z);
m=x>y?x:y;
m=m>z?m:z;
printf("%f",m);
}
3、
main()
{float x,y,z,m;
scanf("%f,%f,%f",&x,&y,&z);
m=x>y?x:y;
printf("Max is %f",m=m>z?m:z);
}
4、main()
{
float a,b,c;
float m,max;
scanf("%f,%f,%f",&a,&b,&c);
max=a>(m=b>c?b:c)?a:m;
printf("the biggest number is:%f",max);
}
5、
float max(float x,float y)
{float m;
m=x>y?x:y;
return(m);
}
main()
{float x,y,z,m;
scanf("%f,%f,%f",&x,&y,&z);
m=max(z,max(x,y));
printf("Max is %f\n",m);
}
6、
sort(float b[3])
{
int i,k;
float t;
k=0;
for(i=1;i<3;i++)
{
if(b[i]>b[k])
k=i;
}
t=b[k];
b[k]=b[0];
b[0]=t;
}
main()
{
float a[3];
int i;
printf("enter the array:\n");
for(i=0;i<=2;i++)
scanf("%f",&a[i]);
sort(a);
printf("the biggest number is:\n%5.2f",a[0]);
}
7、
swap(int *pt1,int *pt2)
{int temp;
temp=*pt1;
*pt1=*pt2;
*pt2=temp;
}
main()
{
int a,b,c,*p1,*p2,*p3;
scanf("%d,%d,%d",&a,&b,&c);
p1=&a;p2=&b;p3=&c;
if(*p1>*p2) swap(p1,p2);
if(*p1>*p3) swap(p1,p3);
if(*p2>*p3) swap(p2,p3);
printf("\nmax=%d\n",c);
}
8、
main()
{int a,b,c,max;
scanf("%d,%d,%d",&a,&b,&c);
max=a;
if(max max=b;
if(max
printf("max=%d",max);
}
9、
main()
{
int a,b,c,t;
scanf("%d,%d,%d",&a,&b,&c);
if(a>b)
{t=a;a=b;b=t;}
if(a>c)
{t=a;a=c;c=t;}
if(b>c)
{t=b;b=c;c=t;}
printf("max=%d",c);
}
10、
main()
{int a[4];
int i,t;
printf("3 number:\n");
for(i=1;i<4;i++)
scanf("%d",&a[i]);
printf("\n");
for(i=1;i<3;i++)
if(a[i]>a[i+1])
{t=a[i+1];a[i+1]=a[i];a[i]=t;}
printf("the sorted number :\n");
printf("%d",a[3]);
}
11、
main()
{
int score(int x[],int n);
int a[3],i;
for(i=0;i<3;i++)
scanf("%d",&a[i]);
score(a,3);
}
int score(int x[],int n)
{
int i,*max;
max=x;
for(i=1;i
printf("\n%d\n",*max);
}
12、
int Max;
main()
{
int high(int,int,int);
int top(int p,int q);
int a,b,c;
scanf("%d,%d,%d",&a,&b,&c);
high(a,b,c);
printf("%d\n",Max);
}
int top(int p,int q)
{
Max=p>q?p:q;
}
int high(int x,int y,int z)
{
if(x
if(y
}
13、
main()
{
int max(int *q,int x[3]);
int *p,a[3],i;
p=a;
for(i=0;i<3;i++)
scanf("%d",p++);
p=a;
max(p,a);
printf("\n%d\n",*p);
}
int max(int *q,int x[3])
{
int i;
q=x;
for(i=1;i<3;i++)
*q=*q>*(x+i)?*q:*(x+i);
}
14、15
main()
{
int a,b,c,d;
scanf("%d%d%d",&a,&b,&c);
d=max(a,b,c);
printf("Max is %d",d);
}
max(int x,int y,int z)
{
int m;
/* if(x>y)
{m=x;x=y;y=m;}
if(y>z)
{m=y;y=z;z=m;}
if(x>z)
{m=x;x=z;z=m;}
return(z);
}*/
m=x>y? x:y;
m=m>z? m:z;
return(m);
}
16、
main()
{
int a,b,c,d,temp;
scanf("%d%d%d",&a,&b,&c);
temp=a>b? a:b;
if(temp>c) printf("%d",temp);
else printf("%d",c);
}
这是我和同学们整理的三个数求最大值得方法
#include"stdio.h"
void main()
{
int a,b,c;
printf("input 3 words\n");
scanf("%d%d%d",&a,&b,&c);
if(a>b&&b>c)
printf("the big is %d,the mid is %d,the small is %d\n",a,b,c);
if(a>c&&c>b)
printf("the big is %d,the mid is %d,the small is %d\n",a,c,b);
if(b>a&&a>c)
printf("the big is %d,the mid is %d,the small is %d\n",b,a,c);
if(b>c&&c>a)
printf("the big is %d,the mid is %d,the small is %d\n",b,c,a);
if(c>b&&b>a)
printf("the big is %d,the mid is %d,the small is %d\n",c,b,a);
if(c>a&&a>b)
printf("the big is %d,the mid is %d,the small is %d\n",c,a,b);
}
我不太习惯用?:语句,不好意思啊。。。
用大小排队的方法,输出 大,小,中:
#include
#include
void main()
{
int a[3];
int i,j,k;
printf("input 3 values\n");
scanf("%d %d %d",&a[0],&a[1],&a[2]);
// 标准的排队算法
for (i=0;i< 2;i++)
for (j=i+1;j<3;j++){
if (a[j] > a[i] ) {k = a[j]; a[j]=a[i];a[i]=k;};
}
printf("%d %d %d ",a[0],a[2],a[1]);
}
#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (aint main(){
int a,b,c,max,mid;
scanf("%d%d%d",&a,&b,&c);
max=MAX(c,MAX(a,b));
min=MIN(c,MIN(a,b));
}
在求三个数谁最大,谁最小的问题时,没有你a>b?(a