SHARE
TWEET

Untitled

a guest Jan 22nd, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <ctime>
  4.  
  5.  
  6. using namespace std;
  7. int main()
  8. {
  9.     int tab[20],l=0,a;
  10.     srand(time(0));
  11.  
  12.  
  13.     for(int i=0;i<20;i++)
  14.     {
  15.         tab[i]=rand()%20;
  16.         cout<<tab[i] <<" ";
  17.     }
  18.  
  19.     cout<<endl;
  20.     cout<<endl;
  21.     cout<<"__________________________________________________________\n";
  22.     cout<<"Podaj liczbe a ja sprawdze czy znajduje sie ona w tablicy\n";
  23.     cin>>a;
  24.  
  25.     for(int i=0;i<20;i++)
  26.     {
  27.         if(tab[i]==a) l=l+1;
  28.         else l=l;
  29.  
  30.     }
  31.     if(l>0) cout<<"Liczba "<<a<<" wystepuje "<<l<<" raz/razy";
  32.     else cout<<"Liczba "<<a<<" nie wystepuje w tablicy";
  33.  
  34.     return 0;
  35. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top