Recent Posts
printf("ho_tari\n");
maxMidMin 본문
#include <stdio.h>
int main(void)
{
int a, b, c;
printf("input 3 num : ");
scanf("%d %d %d", &a, &b, &c);
int max, mid, min;
max = a;
if (b > max)
{
max = b;
}
if (c > max)
{
max = c;
}
min = a;
if (b < min)
{
min = b;
}
if (c < min)
{
min = c;
}
mid = a + b + c - max - min;
printf("max : %d\nmid : %d\nmin : %d\n", max, mid, min);
return 0;
}
#include <stdio.h>
int main(void)
{
int a, b, c;
scanf("%d %d %d", &a, &b, &c);
if (a > b)
{
if (c > a)
{
printf("max: %d mid: %d min: %d\n", c, a, b); //c, a, b
}
else if (c > b)
{
printf("max: %d mid: %d min: %d\n", a, c, b); //a, c, b
}
else
{
printf("max: %d mid: %d min: %d\n", a, b, c); //a, b, c
}
}
else
{
if (c > b)
{
printf("max: %d mid: %d min: %d\n", c, b, a); //c, b, a
}
else if (c > a)
{
printf("max: %d mid: %d min: %d\n", b, c, a); //b, c, a
}
else
{
printf("max: %d mid: %d min: %d\n", b, a, c); //b, a, c
}
}
return 0;
}
#include <stdio.h>
int main(void)
{
int a, b, c;
scanf("%d %d %d", &a, &b, &c);
int max, mid, min;
if (a > b)
{
max = a;
min = b;
}
else
{
max = b;
min = a;
}
if (c > max)
{
mid = max;
max = c;
}
else if (c > min)
{
mid = c;
}
else
{
mid = min;
min = c;
}
printf("max: %d mid: %d min: %d\n", max, mid, min);
return 0;
}
<compile 결과>