Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- const int WMAX=100;
- const int ZMAX=100;
- float A[WMAX][ZMAX];
- int m, n;
- cout<<" Podaj liczbe wierszy <="<<WMAX<<": "<<endl;
- cin>>m;
- cout<<" Podaj liczbe kolumn: <="<<ZMAX<<": "<<endl;
- cin>>n;
- cout<<endl;
- for (int i=0; i<m;i++)
- {
- for (int j=0;j<n;j++)
- {
- cout<<"Podaj wyraz ["<<i+1<<"],["<<j+1<<"]: ";
- cin>>A[i][j];
- }
- }
- //teraz wyczytanie tej tablicy
- for (int i=0; i<m;i++)
- {
- for (int j=0;j<n;j++)
- {
- cout<<"["<<i+1<<"],["<<j+1<<"]: "<<A[i][j]<<" ";
- }
- cout<<endl;
- }
- //srednia arytmetyczna liczb dodatnich tej macierzy
- float suma;
- suma=0;
- int p;
- p=0;
- float srednia;
- for (int i=0; i<m;i++)
- {
- for (int j=0;j<n;j++)
- {
- if ( (A[i][j])>0)
- suma+=A[i][j];
- p++;
- }
- }
- srednia=suma/p;
- cout<<"Srednia liczb dodatnich tej macierzy wynosi: "<<srednia<<". "<<endl;
- //suma elementow zacyznjacych sie na liczbe dodatnia
- float sumax;
- sumax=0;
- int r;
- r=0;
- float sredniax;
- for (int i=0; i<m;i++)
- {
- if ((A[i][0])>0)
- {
- for (int j=0;j<n;j++)
- {
- sumax+=A[i][j];
- r++;
- }
- }
- }
- sredniax=sumax/r;
- cout<<"Suma elementow macierzy ktore leza w wierszach zaczynjacych sie liczba dodatnia wynosi: "<<sredniax<<". "<<endl;
- //wektor ktorego elementami sa najwieksze z poszczegolnych kolumn
- // :<<<<<<<
- const int MA=100;
- float maksimum;
- maksimum=0;
- float B[MA];
- for (int j=0;j<n;j++)
- {
- for (int i=0;i<m-1;i++)
- {
- if (A[i][j]>maksimum)
- maksimum=A[i][j];
- }
- B[j]=maksimum;
- maksimum=0;
- }
- for (int j=0;j<n;j++)
- cout<<B[j]<<" ";
- cout<<endl;
- cout<<endl;
- //suma pierwszego i ostatniego wiersza
- const int DMAX=100;
- float D[DMAX];
- for (int j=0;j<n;j++)
- {
- D[j]= A[0][j]+A[n-1][j] ;
- cout<<D[j]<<" ";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement