I wrote this program, and it does what it asks, but it's so big and ugly. What can I change?
Some examples:
a b c ---> 5 1 12 a is between b and c 5 12 1 a is between c and b 5 5 2 there is no gap
This was in an example of a test that is supposed to be small, so that's why I'm asking if there is another way.
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
int main (void){
int a,b,c;
printf("Inserir 3 números: "); //its in portuguese, insert 3 numbers
scanf("%i %i %i",&a,&b,&c);
if(a==b||b==c||a==b){
printf("não há intervalo\n"); //there is no gap
exit(0);
}
int maior, meio, menor,flag,flag2,flag3;
maior=a; //maior means biggest
flag=1;
if(maior<b){
maior=b;
flag=2;
}if(maior<c){
flag=3;
maior=c;
}
if(maior!=a){
meio=a; //meio means middle
flag2=1;
if(meio<b&&b<maior){
meio=b;
flag2=2;
}if(meio<c&&c<maior){
flag2=3;
}
}else{
meio=b;
flag2=2;
if(meio<c&&c<maior){
flag2=3;
}
}
menor=a; //menor means smallest
flag3=1;
if(menor>b){
menor=b;
flag3=2;
}if(menor>c){
flag3=3;
}
if(flag2==1)
printf("o a entre [");
if(flag2==2)
printf("o b entre [");
if(flag2==3)
printf("o c entre [");
if(flag3==1)
printf("a e ");
if(flag3==2)
printf("b e ");
if(flag3==3)
printf("c e ");
if(flag==1)
printf("a]\n");
if(flag==2)
printf("b]\n");
if(flag==3)
printf("c]\n");
return 0;
}