Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- #include <clocale>
- /*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.*/
- int main(){
- setlocale(LC_ALL, "");
- int const NUMS = 5;
- int vec_num[NUMS];
- bool num_pos = false;
- for(int i =0 ; i<NUMS ; i++){
- cout <<"("<< i + 1 <<")"<< " Ingrese un número"<<endl;
- cin >> vec_num[i];
- }
- cout<< "Los números positivos son: "<<endl;
- for(int j=0 ; j<NUMS ; j++){
- if(vec_num[j]>0){
- if(num_pos = true){
- //cout<< "Los números positivos son: " << endl << vec_num[j]<< "de la posición "<< vec_num[j]+1<< endl;
- cout<< vec_num[j]<<" de la posición "<< j+1 <<endl;
- //cout<<",";
- num_pos= true;
- }
- }
- }
- if (!num_pos){
- cout<<"No hay positivos";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement