Arthur97

q6- apostila

Jan 3rd, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 KB | None | 0 0
  1. #include<iostream>
  2. #include<math.h>
  3.  
  4. using namespace std;
  5.  
  6. int main(){
  7.  
  8.     int n, cont=0;
  9.  
  10.         cout << "Digite o tamanho do vetor" << endl;
  11.             cin >> n;
  12.  
  13.  
  14.     int v[n];
  15.         cout << "digite os componentes ";
  16.         for(int i=0; i<n; i++){
  17.             cin>> v[i];
  18.         }
  19.     int maior = v[0];
  20.         for(int j=0; j<n; j++){
  21.             if(maior<v[j]){
  22.                 maior = v[j];
  23.             }
  24.         }
  25.  
  26.         cout<<"O maior elemnto ocorre nas posicoes: "<<endl;
  27.         for(int k=0; k<n; k++){
  28.             cont++;
  29.                 if(v[k]==maior){
  30.                     cout<<cont<<" ";
  31.                 }
  32.         }
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment