Commit 087c0621 by karlki

esimene ülesanne praktikum 5 zargo, c failid

parent 261dce90
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(void) {
srand(time(NULL));
int maxn = 10;
int maxm = 3;
int A[maxn][maxm];
int negarv = 0;
int negSumRida[4];
int i = 0;
int j = 0;
int negSum;
for(i = 6; i < maxn; i++) {
for(j = 0; j < maxm; j++) {
printf("sisesta %d. rea %d. liige : ", i+1,j+1);
scanf("%d", &A[i][j]);
//A[i][j] = rand() % 200 -100;
//printf("%d \n", A[i][j]);
if (negarv == 0 && A[i][j] < 0) {
negarv = 1;
}
}
}
if (negarv == 0) {
printf("\nMatriksis pole negatiivseid arve, mida kokku summeerida\n");
return;
}
for(i = 6; i < maxn; i++) {
negSum = 0;
for(j = 0; j < maxm; j++) {
if (A[i][j] < 0) {
negSum += A[i][j];
}
}
negSumRida[i-6] = negSum;
}
for (i = 0; i < 4; i++) {
printf("\n%d. rea summa on %d\n",i+7,negSumRida[i]);
}
}
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