Commit 6616bb5b by rallui

Upload New File

parent 8ff81359
Showing with 73 additions and 0 deletions
//Maatriksist lugeda alates kolmandast reast negatiivsete elementide korrutised ja väljastada need kahanevalt.
//Maatriksist lugeda alates kolmandast reast negatiivsete elementide korrutised ja väljastada need kahanevalt.
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
srand(time(NULL));
int n,m,i,j,k,abi;
int MaxN = 15;
int MaxM = 15;
int A[MaxN][MaxM];
int Korrutis[15];
do // Elementide sisestus
{
printf("Sisesta N: ");
scanf("%d" , &n);
printf("Sisesta M: ");
scanf("%d" , &m);
}
while((n < 3|| n > MaxN)|| (m > MaxM || m < 0));
for (i = 0; i < n; i++)
{
for(j = 0; j < m; j++)
{
printf("Element A[%d][%d] : ", i, j);
A[i][j] = rand () % 200 -100; //Suvalised arvud
printf("%d\n", A[i][j]);
}
}
k=0;
for(i = 0; i < n; i++)
{
Korrutis[k] = 1;
for(j=0; j < m; j++)
{
if(A[i][j]<0)
{
Korrutis[k]=Korrutis[k] * A[i][j];
}
}
k++;
}
i=0;
}
for(k=0; k < n-i; k++)
{
for(i=0;i<n-1;i++)
{
for(j=0;j<m-1;j++)
{
if(Korrutis[k]<Korrutis[k+1];
abi=Korrutis[k];
Korrutis[k]=Korrutis[k-1]:
Korrutis[k-1]=abi;
}
}
}
printf("Korrutiseväärtus :%d \n", Korrutis[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