Commit 261dce90 by Karl Kivi

Diagonaali ülesanne

parent 6ec6c414
Showing with 29 additions and 0 deletions
#include <stdio.h>
int main(void) {
int PSum = 0;
int KSum = 0;
int A[4][4] = {{1,2, 3,2}, {1,2,2,4}, {1,2,3,4}, {2,2,3,4}};
for (int i = 0; i <= 3;i++) {
PSum += A[i][i];
KSum += A[0+i][3-i];
}
if (PSum < KSum) {
printf("KSum on %d \n", KSum);
printf("PSum on %d \n", PSum);
} else {
printf("PSum on %d \n", PSum);
printf("KSum on %d \n", KSum);
}
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment