diogoAlves

IFF/Introdução à Programação/Slide/Pag 47/Ex 2

Mar 4th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.71 KB | None | 0 0
  1. //IFF - Introdução à Programação
  2. //Slide - Página 47 - Exercício 2
  3. #include<stdio.h>
  4. #include<locale.h>
  5. #include<locale.h>
  6.  
  7. int main(){
  8.     setlocale(LC_ALL,"Portuguese");
  9.     int vetor1[5], vetor2[5], vetor3[10], aux;
  10.     for(int i=0;i<10;i++){
  11.         if(i<5){
  12.             printf("Entre com a %dª posição do vetor 1:",i+1);
  13.             scanf("%d",&vetor1[i]);
  14.             vetor3[i]=vetor1[i];
  15.         }  
  16.         if(i>=5){
  17.             printf("Entre com a %dª posição do vetor 2:",i-4);
  18.             scanf("%d",&vetor2[i]);
  19.             vetor3[i]=vetor2[i];   
  20.         }
  21.     }
  22.     for(int i=0;i<10;i++){
  23.         for(int c=0;c<10;c++){
  24.             if(vetor3[i]<vetor3[c]){
  25.                 aux=vetor3[i];
  26.                 vetor3[i]=vetor3[c];
  27.                 vetor3[c]=aux;
  28.             }
  29.         }
  30.     }
  31.     for(int i=0;i<10;i++) printf("%d ",vetor3[i]);
  32. }
Advertisement
Add Comment
Please, Sign In to add comment