Guest User

Untitled

a guest
May 27th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1.  
  2. #include <iostream>
  3. #include <string>
  4. #include <vector>
  5. #include <cmath>
  6. #include <fstream>
  7.  
  8. using namespace std;
  9.  
  10.  
  11.  
  12.  
  13. long int maxProd( vector< long int >& in, long int l )
  14. {
  15. long int max = 0;
  16. for( long int i=0; i<in.size()-l; ++i )
  17. {
  18. long int prod = 1;
  19. for( long int j=0; j<l; ++j )
  20. {
  21. prod*=in[i+j];
  22. }
  23. if( max < prod )
  24. {
  25. max = prod;
  26. }
  27. }
  28. return max;
  29. }
  30.  
  31. int main()
  32. {
  33. ios_base::sync_with_stdio( 0 );
  34.  
  35. vector< vector< long int > > in(20);
  36. long int a;
  37. for( long int i=0; i<20; ++i )
  38. {
  39. for( long int j=0; j<20; ++j )
  40. {
  41. cin >> a;
  42. in[i].push_back( a );
  43. }
  44. }
  45.  
  46. vector< vector< long int > > in2( 20 );
  47. for( int i=0; i<20; ++i )
  48. {
  49. for( int j=0; j<20; ++j )
  50. {
  51. in2[i].push_back( in[j][i] );
  52. }
  53. }
  54.  
  55. for( int i=0; i<20; ++i )
  56. {
  57. cout << maxProd( in2[i], 4 ) << endl;
  58. }
  59. /* for( int i=0; i<20; ++i )
  60. {
  61. for( int j=0; j<20; ++j )
  62. cout << in2[i][j] << " ";
  63. cout << endl;
  64. }*/
  65.  
  66. return 0;
  67. }
Add Comment
Please, Sign In to add comment