.


:




:

































 

 

 

 


()




 

//

//

// ,

//

 

#include<iostream.h>

#include <locale.h>

//using namespace std;

 

typedef int telem; //

typedef telem *tstr; // " telem"

typedef tstr *tmatr; // " telem"

void inputmatr(tmatr a, int str, int sto);

void outputmatr(tmatr a, int str, int sto);

telem poisk_str(tmatr a, int str, int sto, int &imax);

 

int main()

{ int i, j;

int imax; //

int n; //

int m; //

tmatr a; // - telem

telem max; //

setlocale(LC_ALL,"Russian");

cout << "\n : ";

cin >> n >> m;

a = new tstr [n]; //

//

for(i = 0; i < n; i++) //

*(a + i) = new telem [m]; //

//

// ,

inputmatr(a, n, m);

cout << " :\n";

outputmatr(a, n, m);

max = poisk_str(a, n, m, imax);

cout << " =" << max << " ";

cout << endl << " " << imax << "- " << endl;

cout << endl << " <Enter>";

//

for(i = 0; i < n; i++)

delete a[i];

delete a;

return 0;

}

 

void inputmatr(tmatr a, int str, int sto)

{ cout << " " << endl;

cout << " " << str << "x" << sto << endl;

cout << " <Enter>" << endl;

for(int i = 0; i < str; i++)

for(int j = 0; j < sto; j++)

cin >> *(*(a + i) + j);

}

 

telem poisk_str(tmatr a, int str, int sto, int &imax)

{telem max, //

pr; //

imax = 0; //, 0-

max = 0;

for(int j = 0; j < sto; j++)

max += *(*(a + 0) + j);

for(int i = 1; i < str; i++)

{pr = 0;

for(j = 0; j < sto; j++)

pr += *(*(a + i) + j);

if(max < pr)

{imax = i;

max = pr;

}

}

return max;

}

 

void outputmatr(tmatr a, int str, int sto)

{ int i, j;

for(i = 0; i < str; i++)

{for(j = 0; j < sto; j++)

cout << *(*(a + i) + j) << ' ';

cout << '\n';

}

}


6





:


: 2015-09-20; !; : 587 |


:

:

.
==> ...

1588 - | 1565 -


© 2015-2024 lektsii.org - -

: 0.008 .