G2A Many GEOs
SHARE
TWEET

Slide 9, Questão 1/a) - Arranjos

Francelmo Apr 6th, 2020 270 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. //Slide 9, Questão 1/a).
  3. int main(){
  4.   int vetor[20];
  5.   int i, cont=0, aux=0;
  6.   printf("Digite valores para o vetor:\n");
  7.   for(i=0; i<20; i++)
  8.     scanf("%d", &vetor[i]);
  9.   for(i=0; i<20; i++)
  10.     if(vetor[i]%5==0)
  11.       cont++;
  12.   int multiplos[cont];
  13.   for(i=0; i<20; i++)
  14.     if(vetor[i]%5==0){
  15.       multiplos[aux] = vetor[i];
  16.       aux++;
  17.     }
  18.   if(cont==0)
  19.     printf("Não existe número multiplo de 5 entre os digitados!\n");
  20.   else
  21.     if(cont==1)
  22.         printf("O valor multiplo de 5 é: {%d}.\n", multiplos[0]);
  23.     else{
  24.       printf("Os valores multiplos de 5 são: { ");
  25.       for(i=0; i<cont; i++)
  26.           printf("%d ", multiplos[i]);
  27.       printf("}.\n");
  28.     }
  29.   return 0;
  30. }
RAW Paste Data
Ledger Nano X - The secure hardware wallet
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top