SHARE
TWEET

Untitled

a guest Jun 18th, 2019 61 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. using namespace std;
  6.  
  7. bool Szukaj(int A[], int n, int liczba)
  8. {
  9.     int licznik = 0;
  10.     for(int i = 0; i < n; ++i)
  11.     {
  12.         if(A[i] == liczba)
  13.             ++licznik;
  14.     }
  15.     if(licznik == 1)
  16.         return true;
  17.     return false;
  18. }
  19.  
  20. void wypelnij_tablice(int* tab, int n)
  21. {
  22.     for(int i = 0; i < n; ++i)
  23.         tab[i] = rand()%101;
  24. }
  25.  
  26. void wypisz_tablice(int* tab, int n)
  27. {
  28.     for(int i = 0; i < n; ++i)
  29.         cout << tab[i] << '\t';
  30.     cout << endl;
  31. }
  32.  
  33. int main()
  34. {
  35.     static_cast<unsigned>(time(nullptr));
  36.     int tab[15];
  37.     wypelnij_tablice(tab, 15);
  38.     int liczba;
  39.     cout << "Podaj liczbe calkowita: ";
  40.     cin >> liczba;
  41.     cout << "Tablica: ";
  42.     wypisz_tablice(tab, 15);
  43.     cout << Szukaj(tab, 15, liczba);
  44.     return 0;
  45. }
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