10 个解决方案
#1
#include <stdio.h>
int main()
{
int a,b,c;
int max,min,result;
printf("请输入三个数:");
scanf("%d %d %d", &a,&b,&c);
max = a>b?a:b;
max = max>c?max:c;
min = a<b?a:b;
min = min<c:min:c;
result = max - min;
printf("最大值和最小值得差为:%d\n", result);
return 0;
}
int main()
{
int a,b,c;
int max,min,result;
printf("请输入三个数:");
scanf("%d %d %d", &a,&b,&c);
max = a>b?a:b;
max = max>c?max:c;
min = a<b?a:b;
min = min<c:min:c;
result = max - min;
printf("最大值和最小值得差为:%d\n", result);
return 0;
}
#2
#3
能不能用if else结构写。谢谢!
#4
#include <stdio.h>
int main()
{
int a,b,c;
int max,min,result;
printf("请输入三个数:");
scanf("%d %d %d", &a,&b,&c);
if (a>b)
{
max=a;
min=b;
}
else
{
max=b;
min=a;
}
if (max<c)
{
max=c;
}
else
{
min=c;
}
result = max - min;
printf("最大值和最小值得差为:%d\n", result);
return 0;
}
#5
#include <stdio.h>
int main()
{
int a,b,c;
int max,min,result;
printf("请输入三个数:");
scanf("%d %d %d", &a,&b,&c);
max = min = a;
if (max<b)
{
max = b;
}
#6
if (max<c)
{
max =c;
}
if (min>b)
{
min = b;
}
if (min>c)
{
min =c;
}
result = max - min;
printf("最大值和最小值得差为:%d\n", result);
return 0;
}
#7
#include<stdio.h>
int main()
{
int a,b,c,max,min,temp;
scanf("%d %d %d",&a,&b,&c);
max=a;min=a;
if(a<b)
max=b;
else
min=b;
if(max<c)
max=c;
if(min>c)
min=c;
temp=max-min;
printf("%d",temp);
return 0;
}
找的
int main()
{
int a,b,c,max,min,temp;
scanf("%d %d %d",&a,&b,&c);
max=a;min=a;
if(a<b)
max=b;
else
min=b;
if(max<c)
max=c;
if(min>c)
min=c;
temp=max-min;
printf("%d",temp);
return 0;
}
找的
#8
这个写的不对吧,如果a=5,b=3,c=4
if (max<c)
{
max=c;
}
else
{
if(c<b)
min=c;
}
#9
正解!楼主还是慢慢习惯这种写法吧!
#10
//给三个变量abc求最大值和最小值的差。高手写下了,谢谢!
#include <stdio.h>
#define M 6
void max(float a[])
{
int i,j,k;
float temp;
for(i=0;i<M-1;i++)
{k=i;
for(j=i+1;j<M;j++)
if(a[i]<a[j]) k=j;
if(i!=k)
{temp=a[k];
a[k]=a[i];
a[i]=temp;
};
};
printf("%f\n",a[0]-a[M-1]);
}
int main (void)
{
int i;
float a[M];
for(i=0;i<M;i++)
scanf("%f",&a[i]);
max(a);
}
这个不单可以求3个最大最小,可以多个
#1
#include <stdio.h>
int main()
{
int a,b,c;
int max,min,result;
printf("请输入三个数:");
scanf("%d %d %d", &a,&b,&c);
max = a>b?a:b;
max = max>c?max:c;
min = a<b?a:b;
min = min<c:min:c;
result = max - min;
printf("最大值和最小值得差为:%d\n", result);
return 0;
}
int main()
{
int a,b,c;
int max,min,result;
printf("请输入三个数:");
scanf("%d %d %d", &a,&b,&c);
max = a>b?a:b;
max = max>c?max:c;
min = a<b?a:b;
min = min<c:min:c;
result = max - min;
printf("最大值和最小值得差为:%d\n", result);
return 0;
}
#2
#3
能不能用if else结构写。谢谢!
#4
#include <stdio.h>
int main()
{
int a,b,c;
int max,min,result;
printf("请输入三个数:");
scanf("%d %d %d", &a,&b,&c);
if (a>b)
{
max=a;
min=b;
}
else
{
max=b;
min=a;
}
if (max<c)
{
max=c;
}
else
{
min=c;
}
result = max - min;
printf("最大值和最小值得差为:%d\n", result);
return 0;
}
#5
#include <stdio.h>
int main()
{
int a,b,c;
int max,min,result;
printf("请输入三个数:");
scanf("%d %d %d", &a,&b,&c);
max = min = a;
if (max<b)
{
max = b;
}
#6
if (max<c)
{
max =c;
}
if (min>b)
{
min = b;
}
if (min>c)
{
min =c;
}
result = max - min;
printf("最大值和最小值得差为:%d\n", result);
return 0;
}
#7
#include<stdio.h>
int main()
{
int a,b,c,max,min,temp;
scanf("%d %d %d",&a,&b,&c);
max=a;min=a;
if(a<b)
max=b;
else
min=b;
if(max<c)
max=c;
if(min>c)
min=c;
temp=max-min;
printf("%d",temp);
return 0;
}
找的
int main()
{
int a,b,c,max,min,temp;
scanf("%d %d %d",&a,&b,&c);
max=a;min=a;
if(a<b)
max=b;
else
min=b;
if(max<c)
max=c;
if(min>c)
min=c;
temp=max-min;
printf("%d",temp);
return 0;
}
找的
#8
这个写的不对吧,如果a=5,b=3,c=4
if (max<c)
{
max=c;
}
else
{
if(c<b)
min=c;
}
#9
正解!楼主还是慢慢习惯这种写法吧!
#10
//给三个变量abc求最大值和最小值的差。高手写下了,谢谢!
#include <stdio.h>
#define M 6
void max(float a[])
{
int i,j,k;
float temp;
for(i=0;i<M-1;i++)
{k=i;
for(j=i+1;j<M;j++)
if(a[i]<a[j]) k=j;
if(i!=k)
{temp=a[k];
a[k]=a[i];
a[i]=temp;
};
};
printf("%f\n",a[0]-a[M-1]);
}
int main (void)
{
int i;
float a[M];
for(i=0;i<M;i++)
scanf("%f",&a[i]);
max(a);
}
这个不单可以求3个最大最小,可以多个