Facebook
From BRT, 5 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 288
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. //  GRUPA C  ZADANIA SPECJALNIE DLA ANGELIKI EM OD BARTŁOMIEJA EL
  5. //ZAD 1
  6. int const nmax=10;
  7. void pobierztablice(int tab[][nmax], int &k, int&w);
  8. int ILEPARZ(int tab[][nmax], int &k, int&w);
  9. void wsywietl(int tab[][nmax], int &k, int&w);
  10. int main()
  11. {
  12.     int tab[nmax][nmax];
  13.     int sr[nmax];
  14.     int k,w;
  15.     pobierztablice(tab,k,w);
  16.       wsywietl(tab,k,w);
  17.     cout<<" ile parzystych w tablicy?"<<ILEPARZ(tab,k,w);
  18.  
  19.  
  20.  
  21.     return 0;
  22. }
  23. void pobierztablice(int tab[][nmax], int &k, int&w)
  24. {
  25.     cout<<"Podaj wiersze";
  26.     cin>>w;
  27.     cout<<"kolyumny";
  28.     cin>>k;
  29.  
  30.     for(int i=0; i<w; i++)
  31.     {
  32.         for(int j=0; j<k; j++)
  33.         {
  34.             cout<<"Podaj tab["<<i<<"]["<<j<<"]";
  35.             cin>>tab[i][j];
  36.         }
  37.     }
  38.  
  39.  
  40.  
  41. }
  42. int ILEPARZ(int tab[][nmax], int &k, int&w)
  43. {
  44.     int ile=0;
  45.     for(int i=0; i<w; i++)
  46.     {
  47.         for(int j=0; j<k; j++)
  48.         {
  49.          if(tab[i][j]%2==0)
  50.             {
  51.                 ile++;
  52.             }
  53.         }
  54.     }
  55.  
  56.     return ile;
  57. }
  58.  
  59.  
  60. void wsywietl(int tab[][nmax], int &k, int&w)
  61. {
  62.     for(int i=0; i<w; i++)
  63.     {
  64.         for(int j=0; j<k;j++)
  65.         {
  66.             cout<<tab[i][j]<<" ";
  67.         }
  68.         cout<<endl;
  69.     }
  70. }
  71.  
  72.  
  73.