SHARE
TWEET

Untitled

a guest Sep 17th, 2019 93 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <ctime>
  4. using namespace std;
  5. int main()
  6. {
  7.     srand(time(NULL));
  8.     const int n = 1000;
  9.     int tab[n], lp=0, lnp=0;
  10.     for (int i=0;i<n;i++)
  11.     {
  12.         int liczba;
  13.         tab[i]=rand()%100;
  14.         cout <<"liczba "<<i<<"= "<<tab[i]<<", \n";
  15.     }
  16.  
  17. cout << endl << "l. parzyste: ";
  18.     for (int i=0;i<n;i++)
  19.     {
  20.         if(tab[i]%2==0)
  21.         {
  22.             cout<<tab[i]<<", ";
  23.             lp++;
  24.         }
  25.     }
  26.  
  27. cout << endl << "l. nieparzyste: ";
  28.     for (int i=0;i<n;i++)
  29.     {
  30.         if(tab[i]%2==1)
  31.         {
  32.             cout<<tab[i]<<", ";
  33.             lnp++;
  34.         }
  35.  
  36.     }
  37.  
  38. cout << endl <<  "Liczb nieparzystych: " << lnp << ", liczb parzystych: " << lp;
  39.  
  40. return 0;
  41. }
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