Commit 7a744cea by sameis

Tunnitöö PR5

parent 1affe2a9
File added
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int n, m, i, j, k;
int MaxN = 10;
int MaxM = 20;
int A[MaxN][MaxM];
int SummaMaatriks[3];
do
{
printf("Sisesta N: ");
scanf("%d" , &n);
printf("Sisesta M: ");
scanf("%d" , &m);
}
while (( n < 7 || n > MaxN || m > MaxM || n < 0));
for(i = 0; i < n; i++)
{
for(j = 0; j < m; j++)
{
printf("Sisesta Element A[%d][%d] : ", i, j);
//scanf("%d", &A[i][j]);
A[i][j] = rand() % 200 -100;
printf("%d\n", A[i][j]);
}
}
k = 0;
for(i = 7; i < n; i++)
{
SummaMaatriks[k] = 0;
for(j=0; j < m; j++)
{
if(A[i][j] < 0)
{
SummaMaatriks[k]=SummaMaatriks[k] + A[i][j];
}
}
k++;
}
i=7;
for(k = 0; k < n - 1; k++)
{
printf("Summav22rtus: %d\n", SummaMaatriks[k]);
}
return 0;
}
File added
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