Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <ctime>
- #include <windows.h>
- #include <iomanip>
- using namespace std;
- int main()
- {
- int w, k, x;
- int suma = 0;
- do
- {
- cout << "Ile wierszy:" << endl;
- cin >> w;
- system("cls");
- }
- while(w<1);
- do
- {
- cout << "Ile kolumn:" << endl;
- cin >> k;
- system("cls");
- }
- while(k<1);
- int matrix[w][k];
- srand(time(NULL));
- for(int i=0; i<w; i++)
- {
- for(int j=0; j<k; j++)
- {
- matrix[i][j]=rand()%100+1;
- }
- }
- do
- {
- cout << "Ktory wiersz macierzy chcesz zsumowac:" << endl;
- cin >> x;
- system("cls");
- }
- while(x>w || x<1);
- cout << "MACIERZ:" << endl;
- for(int i=0; i<w; i++)
- {
- for(int j=0; j<k; j++)
- {
- cout << setw(3) << matrix[i][j] << " ";
- }
- cout << endl;
- }
- for(int j=0; j<k; j++)
- {
- suma = suma + matrix[x-1][j];
- }
- cout << "Suma liczb w wierszu nr: " << x << " wynosi: " << suma << endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment