Commit 013b884b by Jürgen Hein

Update Kodutoo2MassiividLiitmine.c

parent 24029f46
Showing with 27 additions and 27 deletions
/* Kodutöö 2. Variant 4.
/* Kodutöö 2. Variant 4.
......@@ -21,10 +21,10 @@ void CVäljastus(int, int, double[][10]);
int main(void)
{
int n = SisestusN();
int m = SisestusM();
int l = SisestusL();
int k = SisestusK();
int n = SisestusN(); //read
int m = SisestusM(); //veerud
int k = SisestusK(); //read
int l = SisestusL(); //veerud
double A[n][m];
double B[k][l];
int CRida = SisestusCRida(n, k);
......@@ -44,7 +44,7 @@ int SisestusN()
int n;
do
{
printf("Sisestage A veergude arv \n");
printf("Sisestage A ridade arv \n");
scanf("%d", &n);
if(n <= 1 || n >= 10)
{
......@@ -59,7 +59,7 @@ int SisestusM()
int m;
do
{
printf("Sisestage A ridade arv \n");
printf("Sisestage A veergude arv \n");
scanf("%d", &m);
if(m <= 1 || m >= 10)
{
......@@ -69,38 +69,38 @@ int SisestusM()
return m;
}
int SisestusL()
int SisestusK()
{
int l;
int k;
do
{
printf("Sisestage B veergude arv \n");
scanf("%d", &l);
if(l <= 1 || l >= 10)
printf("Sisestage B ridade arv \n");
scanf("%d", &k);
if(k <= 1 || k >= 10)
{
printf("Sisestatud väärtus ei sobi, sisestage täisarv vahemikus 1...10.");
}
} while(l <= 1 || l >= 10);
return l;
} while(k <= 1 || k >= 10);
return k;
}
int SisestusK()
int SisestusL()
{
int k;
int l;
do
{
printf("Sisestage B ridade arv \n");
scanf("%d", &k);
if(k <= 1 || k >= 10)
printf("Sisestage B veergude arv \n");
scanf("%d", &l);
if(l <= 1 || l >= 10)
{
printf("Sisestatud väärtus ei sobi, sisestage täisarv vahemikus 1...10.");
}
} while(k <= 1 || k >= 10);
return k;
} while(l <= 1 || l >= 10);
return l;
}
int SisestusCRida(int n, int k)
int SisestusCRida(int n, int k) //miinimum ridade arvu leidmine
{
int CRida;
if(n < k)
......@@ -112,7 +112,7 @@ int SisestusCRida(int n, int k)
}
return CRida;
}
int SisestusCVeerg(int m, int l)
int SisestusCVeerg(int m, int l) //miinimum veergude arvu leidmine
{
int CVeerg;
if(m < l)
......@@ -128,9 +128,9 @@ int SisestusCVeerg(int m, int l)
void MaatriksSisestus(int n, int m, int k, int l, double A[][m], double B[][l])
{
int i, j, Kontroll; //järjenumbrid, scanf kontrolli muutuja
for(i=0;i<m;i++)
for(i=0;i<m;i++) //veergude tsükkel
{
for(j=0;j<n;j++)
for(j=0;j<n;j++) //ridade tsükkel
{
do
{
......@@ -144,9 +144,9 @@ void MaatriksSisestus(int n, int m, int k, int l, double A[][m], double B[][l])
} while(Kontroll == 0); //reaalarvu kontroll
}
}
for(i=0;i<k;i++)
for(i=0;i<l;i++) //veergude tsükkel
{
for(j=0;j<l;j++)
for(j=0;j<k;j++) //ridade tsükkel
{
do
{
......
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