Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <Windows.h>
- #include <time.h>
- #include <ctime>
- #include <cstdlib>
- #include <iomanip>
- using namespace std;
- int main() {
- int n, m,w; // indeks wiersza/kolumny/kasowanego wiersza
- int A[100][100];
- srand(time(NULL));
- cout << "Podaj wymiar n tablicy: "; cin >> n;
- cout << "Podaj wymiar m tablicy: "; cin >> m;
- //generowanie tablicy A
- for (int i = 0; i < n; i++)
- {
- for (int j = 0; j < m; j++)
- {
- A[i][j] = rand() % 10 + 1;
- }
- }
- //wyswietlanie tablicy A
- for (int i = 0; i < n; i++)
- {
- for (int j = 0; j < m; j++)
- {
- cout << setw(3)<<A[i][j];
- }
- cout << endl;
- }
- //usuwanie podanego wierszu (n)
- cout << "Podaj indeks wiersza ktory chcesz skasowac: "; cin >> w;
- for (int i = 0; i < n-1; ++i)
- {
- if (i < w-1) {
- for (int j = 0; j < m; j++)
- {
- cout << setw(3) << A[i][j];
- }
- cout << endl;
- }
- else
- {
- for (int j = 0; j < m; j++)
- {
- A[i][j] = A[i+1][j];
- cout << setw(3) << A[i][j];
- }
- cout << endl;
- }
- }
- system("PAUSE");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement