Advertisement
Dev4ster

teste meu

Sep 24th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.40 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3.  
  4. int main() {
  5.   int vetor[] = {2,6,7,10};
  6.   int soma = 0;
  7.   int tamanhoVetor = sizeof(vetor)/sizeof(int);
  8.   double meioDoVetor = tamanhoVetor/2;
  9.   meioDoVetor = ceil(meioDoVetor);
  10.  
  11.   int vetorCoringa = vetor[(int) meioDoVetor];
  12.  
  13.   for(int i = 0;i<tamanhoVetor;i++){
  14.     if(vetor[i]!=vetorCoringa){
  15.       soma+=vetor[i];
  16.     }
  17.   }
  18.   std::cout<<"y="<<soma;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement