#include #include int main(int argc, char *argv[]) { double v1,v2,v3; double temp; /* Ler 3 números reais */ printf("Entre com 3 numeros... \n"); printf("Digite o nro. 1: "); scanf ("%lf",&v1); printf("Digite o nro. 2: "); scanf ("%lf",&v2); printf("Digite o nro. 3: "); scanf ("%lf",&v3); /* Os 3 são iguais? */ if ((v1 == v2) && (v2 == v3)) { printf("\n\n>> Numeros iguais! <<\n\n"); system("PAUSE"); return 0; } if (v1 > v2) /* Troca V1 com V2 */ { temp=v1; v1=v2; v2=temp; } /* Atualmente v1 é o menor e v2 é o maior */ if (v2 > v3) /* Troca V2 com V3 */ { temp=v2; v2=v3; v3=temp; } /* Atualmente v3 é o maior de todos... mas e entre v1 e v2 depois das trocas? */ if (v1 > v2) /* Troca V1 com V2 */ { temp=v1; v1=v2; v2=temp; } /* Atualmente v1 é o menor de todos... logo v2 não é nem o maior, nem o menor */ printf("Os numeros ordenados sao: %.3lf => %.3lf => %.3lf\n\n",v1,v2,v3); system("PAUSE"); return 0; }