Facebook
From BRT, 4 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 236
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. //  GRUPA C  ZADANIA SPECJALNIE DLA ANGELIKI EM OD BARTŁOMIEJA EL
  5. //ZAD 2
  6. int const nmax=10;
  7. void pobierztablice(double tab[][nmax], int &k, int&w);
  8. void wsywietl(double tab[][nmax], int &k, int&w);
  9. void ujemnekolumnami(double tab[][nmax], int&k, int&w, double ile[]);
  10. int main()
  11. {
  12.     double tab[nmax][nmax];
  13.     int k,w;
  14.     double ile[nmax];
  15.     pobierztablice(tab,k,w);
  16.       wsywietl(tab,k,w);
  17.     ujemnekolumnami(tab,k,w,ile);
  18.  
  19.  
  20.  
  21.     return 0;
  22. }
  23. void pobierztablice(double 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.  
  43. void wsywietl(double tab[][nmax], int &k, int&w)
  44. {
  45.     for(int i=0; i<w; i++)
  46.     {
  47.         for(int j=0; j<k;j++)
  48.         {
  49.             cout<<tab[i][j]<<" ";
  50.         }
  51.         cout<<endl;
  52.     }
  53. }
  54. void ujemnekolumnami(double tab[][nmax], int&k, int&w, double ile[])
  55. {
  56.     for(int i=0; i<k; i++)
  57.     {
  58.  
  59.         ile[i]=0;
  60.  
  61.         for(int j=0; j<w; j++)
  62.         {
  63.             if(tab[j][i]<0)
  64.                 ile[i]++;
  65.         }
  66.      cout<<"W kolumnie "<<i<<" jest "<<ile[i]<<" liczb ujemnych"<<endl;
  67.  
  68.     }
  69.  
  70. }
  71.  
  72.  
  73.