Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <ctype.h>
- int main()
- {
- int n, m;
- scanf("%d%d", &n, &m);
- int mat[n + 1][m + 1];
- for(int i = 0; i < n; i++) {
- for(int j = 0; j < m; j++) {
- scanf("%d", &mat[i][j]);
- }
- }
- int xi, xj;
- scanf("%d%d", &xi, &xj);
- int prv_kvadrant = 0;
- int vtor_kvadrant = 0;
- int tret_kvadrant = 0;
- int cetvrt_kvadrant = 0;
- for(int i = 0; i < n; i++) {
- for(int j = 0; j < m; j++) {
- if(i < xi && j >= xj) {
- prv_kvadrant += mat[i][j]; // prviot kvadrant se naoga striktno pogore od x, i na desno strana od x
- }
- else if(i < xi && j < xj) {
- vtor_kvadrant += mat[i][j];
- }
- else if(i >= xi && j < xj) {
- tret_kvadrant += mat[i][j];
- }
- else {
- cetvrt_kvadrant += mat[i][j];
- }
- }
- }
- printf("%d\n%d\n%d\n%d\n", prv_kvadrant, vtor_kvadrant, tret_kvadrant, cetvrt_kvadrant);
- return 0;
- }
- /*
- 5 3
- 1 3 6
- 2 0 7
- 4 -5 100
- 10 22 15
- 18 2 7
- 2 1
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement