Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- int w,k, wiersz=0, suma=0;
- int main()
- {
- srand(time(NULL));
- int tab[w][k];
- cout << "Podaj ilosc wierszy: ";
- cin >> w;
- cout << "Podaj ilosc kolumn: ";
- cin >> k;
- cout<<"Podaj wiersz ktory chcesz zsumowac:";
- cin>>wiersz;
- if(wiersz>w || wiersz<=0)
- {
- cout<<"Podaj poprawny wiersz";
- return 0;
- }
- for(int i=1; i<=w; i++)
- {
- for(int j=1; j<=k; j++)
- {
- tab[i][j] = rand()%100+1;
- }
- }
- for(int j=1; j<=k; j++)
- {
- suma = suma + tab[wiersz][j];
- }
- cout << "Suma liczb w wierszu nr. "<<wiersz<<" wynosi: "<< suma <<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement