Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <time.h>
- #include <cstdlib>
- using namespace std;
- int main()
- {
- cout << "Podaj ilosc wierszy" << endl;
- int w;
- int k;
- int licznik=0;
- cin >>w;
- cout<< "Podaj ilosc kolumn" << endl;
- cin >>k;
- float suma=0;
- int macierz [w][k];
- srand(time(NULL));
- for (int i=0; i<k; i++){
- for(int j=0; j<w; j++){
- macierz[j][i]=rand()%100+1;
- licznik++;
- suma+=macierz[j][i];
- }
- }
- cout<<"Elementow jest"<<licznik<<endl;
- cout<<"Suma wszystkich elementow to: "<<suma<< endl;
- cout<<"Srednia wszystkich elementow to: "<<suma/licznik<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment