Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. #include <iostream>
  2. #include <Windows.h>
  3. #include <time.h>
  4. #include <ctime>
  5. #include <cstdlib>
  6. #include <iomanip>
  7. using namespace std;
  8.  
  9.  
  10. int main() {
  11. int n, m,w; // indeks wiersza/kolumny/kasowanego wiersza
  12. int A[100][100];
  13. srand(time(NULL));
  14.  
  15. cout << "Podaj wymiar n tablicy: "; cin >> n;
  16. cout << "Podaj wymiar m tablicy: "; cin >> m;
  17.  
  18. //generowanie tablicy A
  19.  
  20. for (int i = 0; i < n; i++)
  21. {
  22. for (int j = 0; j < m; j++)
  23. {
  24. A[i][j] = rand() % 10 + 1;
  25. }
  26. }
  27.  
  28. //wyswietlanie tablicy A
  29.  
  30. for (int i = 0; i < n; i++)
  31. {
  32. for (int j = 0; j < m; j++)
  33. {
  34. cout << setw(3)<<A[i][j];
  35. }
  36. cout << endl;
  37. }
  38.  
  39. //usuwanie podanego wierszu (n)
  40.  
  41. cout << "Podaj indeks wiersza ktory chcesz skasowac: "; cin >> w;
  42.  
  43. for (int i = 0; i < n-1; ++i)
  44. {
  45.  
  46. if (i < w-1) {
  47. for (int j = 0; j < m; j++)
  48. {
  49. cout << setw(3) << A[i][j];
  50. }
  51. cout << endl;
  52. }
  53. else
  54. {
  55. for (int j = 0; j < m; j++)
  56. {
  57. A[i][j] = A[i+1][j];
  58. cout << setw(3) << A[i][j];
  59. }
  60. cout << endl;
  61. }
  62.  
  63. }
  64.  
  65.  
  66.  
  67. system("PAUSE");
  68. return 0;
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement