fork download
  1. // Proba 4.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5.  
  6.  
  7. class macierz
  8. {
  9. private:
  10. int szer;
  11. int wys;
  12. int **tab;
  13.  
  14. public:
  15. macierz(int szer1, int wys1);
  16. macierz();
  17.  
  18.  
  19. int pobierzSzerokosc()
  20. {
  21. return szer;
  22. }
  23.  
  24.  
  25.  
  26. int pobierzWysokosc()
  27. {
  28. return wys;
  29. }
  30.  
  31. void wypelnij()
  32. {
  33. for(int i = 0 ; i < wys ; i++)
  34. for (int j = 0; j < szer ; j++)
  35. cin >> tab[i][j];
  36. }
  37.  
  38. void wyswietl()
  39. {
  40. for(int i = 0 ; i < wys ; i++)
  41. {
  42. cout << endl;
  43. for (int j = 0; j < szer ; j++)
  44. cout << tab[i][j] << " ";
  45. }
  46. }
  47.  
  48. void wyswiersze(int ktoryw)
  49. {
  50. for (int i = 0; i < szer ; i++)
  51. cout << tab[ktoryw][i] << " ";
  52.  
  53. }
  54.  
  55.  
  56. void wyskolumny(int ktorakol)
  57. {
  58. for (int i = 0; i < szer ; i++)
  59. cout << tab[i][ktorakol] << endl;
  60.  
  61. }
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68. };
  69.  
  70.  
  71. macierz::macierz(int szer1 = 5, int wys1 = 5) //konstruktor
  72. {
  73.  
  74. szer = szer1;
  75. wys = wys1;
  76.  
  77. tab = new int*[wys];
  78. for (int x = 0 ; x < wys ; x++)
  79. {
  80. tab[x] = new int[szer];
  81. }
  82. }
  83.  
  84.  
  85. void dodaj()
  86. {
  87.  
  88.  
  89.  
  90.  
  91.  
  92. int main()
  93. {
  94. int a,b,c,d;
  95.  
  96.  
  97.  
  98. cout << "Podaj wymiary pierwszej macierzy: " << endl;
  99. cout << "Szerokosc: "; cin >> a;
  100. cout << "Dlugosc: "; cin >> b; cout << endl;
  101.  
  102. macierz pierwsza(a,b);
  103.  
  104. cout << "Macierz ma wymiary " << pierwsza.pobierzSzerokosc() << "x" << pierwsza.pobierzWysokosc() << endl;
  105. cout << "Wprowadz liczby do macierzy:" << endl;
  106. pierwsza.wypelnij();
  107. cout << endl << "Oto twoja macierz: " << endl;
  108. pierwsza.wyswietl();
  109.  
  110. cout << endl << "Podaj jaki wiersz chcesz zobaczyc: " << endl;
  111. cin >> c;
  112. cout << endl << endl;
  113. pierwsza.wyswiersze(--c);
  114.  
  115. cout << endl << "Podaj jaka kolumne chcesz zobaczyc: " << endl;
  116. cin >> d;
  117. cout << endl << endl;
  118. pierwsza.wyskolumny(--d);
  119.  
  120.  
  121.  
  122.  
  123. /*
  124.   cout << pierwsza.pobierzSzerokosc() << endl;;
  125.   cout << pierwsza.pobierzWysokosc();
  126.  
  127.   pierwsza.wypelnij();
  128.   pierwsza.wyswietl();
  129. */
  130.  
  131. system("pause");
  132. return 0;
  133. }
  134.  
  135.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:4:20: fatal error: stdafx.h: No such file or directory
compilation terminated.
stdout
Standard output is empty