Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- #include <cmath>
- #include <fstream>
- using namespace std;
- long int maxProd( vector< long int >& in, long int l )
- {
- long int max = 0;
- for( long int i=0; i<in.size()-l; ++i )
- {
- long int prod = 1;
- for( long int j=0; j<l; ++j )
- {
- prod*=in[i+j];
- }
- if( max < prod )
- {
- max = prod;
- }
- }
- return max;
- }
- int main()
- {
- ios_base::sync_with_stdio( 0 );
- vector< vector< long int > > in(20);
- long int a;
- for( long int i=0; i<20; ++i )
- {
- for( long int j=0; j<20; ++j )
- {
- cin >> a;
- in[i].push_back( a );
- }
- }
- vector< vector< long int > > in2( 20 );
- for( int i=0; i<20; ++i )
- {
- for( int j=0; j<20; ++j )
- {
- in2[i].push_back( in[j][i] );
- }
- }
- for( int i=0; i<20; ++i )
- {
- cout << maxProd( in2[i], 4 ) << endl;
- }
- /* for( int i=0; i<20; ++i )
- {
- for( int j=0; j<20; ++j )
- cout << in2[i][j] << " ";
- cout << endl;
- }*/
- return 0;
- }
Add Comment
Please, Sign In to add comment