Advertisement
orlandoju

ejer1bis_tp6

May 12th, 2024
708
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.94 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. #include <clocale>
  4.  
  5. /*Hacer un programa que le pida al usuario una lista de 10 números enteros y luego de ingresarlos muestre cuáles de ellos fueron positivos.*/
  6.  
  7.  int main(){
  8.     setlocale(LC_ALL, "");
  9.     int const NUMS = 5;
  10.     int vec_num[NUMS];
  11.     bool num_pos = false;
  12.     for(int i =0 ; i<NUMS ; i++){
  13.     cout <<"("<< i + 1 <<")"<< " Ingrese un número"<<endl;
  14.         cin >> vec_num[i];
  15.     }
  16.  
  17.     cout<< "Los números positivos son: "<<endl;
  18.  
  19.     for(int j=0 ; j<NUMS ; j++){
  20.         if(vec_num[j]>0){
  21.             if(num_pos = true){
  22.             //cout<< "Los números positivos son: " << endl << vec_num[j]<< "de la posición "<< vec_num[j]+1<< endl;
  23.             cout<< vec_num[j]<<" de la posición "<< j+1 <<endl;
  24.             //cout<<",";
  25.             num_pos= true;
  26.             }
  27.  
  28.        }
  29.     }
  30.     if (!num_pos){
  31.     cout<<"No hay positivos";
  32.     }
  33.     return 0;
  34.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement