Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int a,b,c,d;
- int m[5][5]; // arreglo de 10 enteros
- for ( int i = 1; i < 6; i++ )
- {
- for ( int j = 1; j < 6; j++ )
- {
- m[i][j] = 3; // valor cero
- cout << "\t" << m[i][j];
- }
- cout << endl;
- }
- for ( int i=2; i<5; i++ )
- {
- for ( int j=2; j<5; j++ )
- {
- a=b=c=d=0;
- for ( int x=1; x<i; x++ )
- {
- for ( int y=1; y<j; y++ )
- {
- a=a+m[x][y];
- }
- }
- for ( int x=i+1; x<6; x++ )
- {
- for ( int y=1; y<j; y++ )
- {
- b=b+m[x][y];
- }
- }
- for ( int x=1; x<i; x++ )
- {
- for ( int y=j+1; y<6; y++ )
- {
- c=c+m[x][y];
- }
- }
- for ( int x=i+1; x<6; x++ )
- {
- for ( int y=j+1; y<6; y++ )
- {
- d=d+m[x][y];
- }
- }
- cout << a << " " << b << " " << c << " " << d << endl;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement