Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <cstdlib>
- #include <ctime>
- #include <string>
- using namespace std;
- int rozmiar()
- {
- int rozmiar;
- cout<<"Podaj rozmiar tablicy:"<<endl;
- cin>>rozmiar;
- while(rozmiar<5||rozmiar>15||rozmiar==0)
- {
- cout<<"Podaj rozmiar tablicy"<<endl;
- cin>>rozmiar;
- }
- return rozmiar;
- }
- void losowanie(int n,int t[][15])
- {
- srand(time(NULL));
- for(int i=0;i<n;i++)
- {
- for(int j=0;j<15;j++)
- {
- t[i][j]=rand()%201-100;
- }
- }
- }
- int wyswietlanie(int n, int t[][15])
- {
- for(int i=0;i<n;i++)
- {
- for(int j=0;j<15;j++)
- {
- cout << t[i][j] << " ";
- }
- cout << endl;
- }
- }
- void dzialania(int n, int t[][15])
- {
- int iloscplus=0,ilosczer=0,suma=0,srednia=0;
- for(int i=0;i<n;i++)
- {
- for(int j=0;j<15;j++)
- {
- if(t[i][j]>0)
- {
- iloscplus +=1;
- }
- if(t[i][j]==0)
- {
- ilosczer +=1;
- }
- suma +=t[i][j];
- }
- }
- srednia += suma/(n+1) *16;
- cout<<"Ilosc elementow wiekszych od 0:"<<iloscplus<<endl;
- cout<<"Ilosc zer:"<<ilosczer<<endl;
- cout<<"suma:"<<suma<<endl;
- cout<<"srednia:"<<srednia<<endl;
- }
- int main()
- {
- int n=rozmiar();
- int t[n][15];
- losowanie(n,t);
- wyswietlanie(n,t);
- dzialania(n,t);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement