Advertisement
Mastercpp

numero mayor de vectores

Sep 19th, 2015
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5.  
  6. int main(){
  7.     string nombres[3];
  8.     int edades[3];
  9.    
  10.     for(int i=0; i<3; i++){
  11.        
  12.         cout << "ingrese nombre: ";
  13.         cin>>nombres[i];
  14.        
  15.         cout << "ingrese edad: ";
  16.         cin>>edades[i];
  17.     }
  18.    
  19.    
  20.     int mayor = edades[0];
  21.     int posicion = 0;
  22.    
  23.    
  24.     for(int i =0; i<3; i++){
  25.         if(edades[i] > mayor){
  26.             mayor = edades[i];
  27.             posicion = i;
  28.         }
  29.     }
  30.    
  31.     cout << "La edad mas mayor es " <<mayor  << " y se llama " << nombres[posicion] << endl;
  32.    
  33.    
  34.     cin.get();
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement