Vardas:
Pavardė:
Klasė:
Masyvas 1.6 (Ūgiai - programos analizė)
Parengė ITMM Artūras Šakalys
Įrašykite teisingą atsakymą.
// sąlyga rasite: Ûgiai - vadovėlis 49 psl.
#include <
>
#include <
>
#include
#include
using namespace std;
const char CDfv[] = "Duomenys6_u2.txt";
const
CRfv[] = "Rezultatai6_u2.txt";
const int CMax = 31;
//-------------------------------------------------------------------
void Skaityti(int A[], int & n, int A1[], int & n1, int A2[], int & n2);
int
(int A[], int n);
int Kiek (int A[], int n);
//-------------------------------------------------------------------
int main()
{
int VV[CMax]; int n; int V[CMax]; int nv; int M[CMax]; int nm;
Skaityti(VV, n, V, nv, M, nm);
ofstream fr(CRfv);
fr << fixed << setprecision(1) << (double) Suma(VV, n) / n << endl;
fr << fixed << setprecision(2) << (double) Suma(M, nm) / nm << endl;
fr << fixed << setprecision(2) << (double)
<< endl;
if (
) fr << "Merginu komanda sudaryti galima" << endl;
else fr << "Merginu komandos sudaryti negalima" << endl;
if (
) fr << "Vaikinu komanda sudaryti galima" << endl;
else fr << "Vaikinu komandos sudaryti negalima" << endl;
fr.close();
return 0;
}
//-------------------------------------------------------------------
void Skaityti(int A[], int & n, int A1[], int & n1, int A2[],
)
{
ifstream fd(CDfv);
fd >>
;
n1 = 0; n2 = 0;
int u;
for (
) {
fd >> u;
;
if (
) {
A2[n2] = u;
n2 = n2 + 1;
}
else {
A1[n1] = fabs(u);
;
}
}
fd.close();
}
//-------------------------------------------------------------------
int Suma(int A[], int n)
{
int
;
for (
) s = s + A[i];
return s;
}
//-------------------------------------------------------------------
int Kiek(int A[], int n)
{
int s = 0;
for (int i = 0; i < n; i++) if (
) s =
;
return s;
}
Paspausk
Gerai