Jvsierra

Ordem Crescente de 3 números

Feb 8th, 2018
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.75 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4.  
  5. int main(){
  6.  
  7.   int n1 = 0, n2 = 0, n3 = 0;
  8.  
  9.   printf("Digite o primeiro numero:\n");
  10.   scanf("%d", &n1);
  11.   printf("Digite o segundo numero:\n");
  12.   scanf("%d", &n2);
  13.   printf("Digite o terceiro numero:\n");
  14.   scanf("%d", &n3);
  15.  
  16.   if(n1 > n2 && n1 > n3){
  17.     if(n2 > n3){
  18.         printf("%d, %d, %d", n3, n2, n1);
  19.     }else{
  20.         printf("%d, %d, %d", n2, n3, n1);
  21.     }
  22.   }else if(n2 > n1 && n2 > n3){
  23.     if(n1 > n3){
  24.         printf("%d, %d, %d\n", n3, n1,n2);
  25.     }else{
  26.         printf("%d, %d, %d", n1, n3, n2);
  27.     }
  28.   }else{
  29.     if(n1 > n2){
  30.         printf("%d, %d, %d\n", n2, n1,n3);
  31.     }else{
  32.         printf("%d, %d, %d\n", n1, n2,n3);
  33.     }
  34.   }
  35.  
  36.   return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment