orlandoju

Ejer2_tp6

May 18th, 2022
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.93 KB | None | 0 0
  1. /*
  2. Hacer un programa donde se carguen 15 números enteros y luego le
  3. solicite al usuario un número e indique si el mismo pertenece a
  4. la lista cargada anteriormente.
  5. */
  6.  
  7.  
  8. #include <iostream>
  9. using namespace std;
  10.  
  11. int main(void){
  12.   int i,x;
  13.     int num15[4];
  14.     int num15bis;
  15.     bool flagpertenece=false;
  16.     for(i=0 ; i<4; i++){
  17.  
  18.         cout<<"Ingrese un numero: "<<endl;
  19.         cin>>num15[i];
  20.      }
  21.      cout<<"------------------"<<endl;
  22.      cout<<"Ingrese un numero y le diremos si pertenece a la lista anterior: "<<endl;
  23.         cin>>num15bis;
  24.         for(i=0; i<4;i++)
  25.         {
  26.  
  27.             if(num15bis==num15[i]){
  28.                     flagpertenece=true;
  29.             }
  30.        }
  31.        if(flagpertenece==true)
  32.        {
  33.            cout<<"El numero pertenece a la lista ingresada"<<endl;
  34.        }
  35.             else {
  36.                 cout<<"No pertenece a la lista ingresada"<<endl;
  37.             }
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment