Commit 84657d60 by lilepp

tunnitoo5

parent 047fbaf2
Showing with 58 additions and 0 deletions
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
srand(time(NULL));
int n , m , i , j , k;
int MaxN = 10;
int MaxM = 20;
int A[MaxN][MaxM];
int Sumk[3];
do
{
printf("Sisesta N: ");
scanf("%d", &n);
}while( n < 7 || n > MaxN) ;
do
{
printf("Sisesta M: ");
scanf("%d", &m);
}while( m > MaxM || m < 0);
for(i = 0; i < n; i++)
{
for(j = 0; j < m; j++)
{
printf("Sisesta element A[%d][%d] : " , i ,j);
A[i][j] = rand() % 200 - 100 ;
printf("%d\n", A[i][j]);
}
}
k = 0;
for(i = 7; i < n; i++)
{
Sumk[k] = 0;
for(j = 0; j < m; j++)
{
if(A[i][j] < 0)
{
Sumk[k] = Sumk[k] + A[i][j];
}
}
k++;
}
i = 7;
for(k = 0; k < n-i; k++)
{
printf("Väljasta summa: %d \n", Sumk[k]);
}
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