[cpp]
//輸出三個數中中間的數
#include<stdio.h>
void main()
{
int a,b,c,middle;
printf("請輸入三個數:\n");
scanf("%d%d%d",&a,&b,&c);
if(a>b&&a<c||a>c&&a<b)
{
printf("middle=%d\n",a);
}
if(b>a&&b<c||b>c&&b<a)
{
printf("middle=%d\n",b);
}
if(c>a&&c<b||c>b&&c<a)
{
printf("middle=%d\n",c);
}
}
//輸出三個數中中間的數
#include<stdio.h>
void main()
{
int a,b,c,middle;
printf("請輸入三個數:\n");
scanf("%d%d%d",&a,&b,&c);
if(a>b&&a<c||a>c&&a<b)
{
printf("middle=%d\n",a);
}
if(b>a&&b<c||b>c&&b<a)
{
printf("middle=%d\n",b);
}
if(c>a&&c<b||c>b&&c<a)
{
printf("middle=%d\n",c);
}
}
[cpp]
//按照從小到大的順序順出三個數
#include<stdio.h>
void main()
{
int a,b,c,s;
printf("請輸入三個數:\n");
scanf("%d%d%d",&a,&b,&c);
if(a>b)
{
s=a;a=b;b=s;
}
if(a>c)
{
s=a;a=c;c=s;
}
if(b>c)
{
s=b;b=c;c=s;
}
printf("%d %d %d\n",a,b,c);
}
//按照從小到大的順序順出三個數
#include<stdio.h>
void main()
{
int a,b,c,s;
printf("請輸入三個數:\n");
scanf("%d%d%d",&a,&b,&c);
if(a>b)
{
s=a;a=b;b=s;
}
if(a>c)
{
s=a;a=c;c=s;
}
if(b>c)
{
s=b;b=c;c=s;
}
printf("%d %d %d\n",a,b,c);
}