如题所述
#include <stdio.h>
#include <stdlib.h>
int min(int a,int b)
{
if(a>b)
return b;
else
return a;
}
int max(int a,int b)
{
if(a>b)
return a;
else
return b;
}
int main()
{
printf("请输入学生的成绩:\n");
int as,sd,df;
scanf("%d%d%d",&as,&sd,&df);
printf("最高成绩是:%d\n",max(as,max(sd,df)));
printf("最低成绩是:%d",min(as,min(sd,df)));
return 0;
}
#include <stdlib.h>
int min(int a,int b)
{
if(a>b)
return b;
else
return a;
}
int max(int a,int b)
{
if(a>b)
return a;
else
return b;
}
int main()
{
printf("请输入学生的成绩:\n");
int as,sd,df;
scanf("%d%d%d",&as,&sd,&df);
printf("最高成绩是:%d\n",max(as,max(sd,df)));
printf("最低成绩是:%d",min(as,min(sd,df)));
return 0;
}
温馨提示:答案为网友推荐,仅供参考
第1个回答 2015-03-27
#include <stdio.h>
#include <stdlib.h>
void main()
{
int c1,c2,c3,max,min;
scanf("%d %d %d",&c1,&c2,&c3); //输入三门成绩
max = c1;
min = c1;
max = max > c2 ? max:c2; //判断 c1 和 c2 哪个大
min = min < c2 ? min:c2;
max = max > c3 ? max:c3;
min = min < c3 ? min:c3;
printf("%d %d\n",max,min);
}
#include <stdlib.h>
void main()
{
int c1,c2,c3,max,min;
scanf("%d %d %d",&c1,&c2,&c3); //输入三门成绩
max = c1;
min = c1;
max = max > c2 ? max:c2; //判断 c1 和 c2 哪个大
min = min < c2 ? min:c2;
max = max > c3 ? max:c3;
min = min < c3 ? min:c3;
printf("%d %d\n",max,min);
}
第2个回答 2015-03-27
#include<stdio.h>
void main()
{
float a[3] = {0};
float min,max;
for(i=0;i<3;i++)
{
scanf("%f",a+i);
}
max=a[0];
min=a[0];
for(i=0;i<3;i++)
{
max=a[i]>max?a[i]:max;
min=a[i]<min?a[i]:min;
}
printf("max:%f\n",max);
printf("min:%f\n".min);
}
void main()
{
float a[3] = {0};
float min,max;
for(i=0;i<3;i++)
{
scanf("%f",a+i);
}
max=a[0];
min=a[0];
for(i=0;i<3;i++)
{
max=a[i]>max?a[i]:max;
min=a[i]<min?a[i]:min;
}
printf("max:%f\n",max);
printf("min:%f\n".min);
}