Ответы к экзамену 1
.0.pdfWRITE (<номер КГВых>, <тег>, <список выходов>, <список переменных>) READ (<номер КГВх>, <тег>, <список входов>, <список переменных>) OUT (<номер КГВых>, <тег>, <список выходов>, <список переменных>) CHECK(<номер КГВх>, <тег>, <список входов>, <переменная>)
<список выходов>
KILL(<список имен уничтожаемых процессов>)
<имя модуля>.<номер КГВх>.<имя подпрограммы>.<имя тега>
√
|
|
|
√ |
|
void startup()
{
float data[5] = {5, 20, 40, 0.001, 10}; // a, b, c, eps, x0
int place[5] = {1, 2, 3, 4, 5}; out(1, 0, place, data);
}
void Multiplication1(int tag, float x1, float x2)
{
float data[2];
data[0] = x1;
data[1] = x1 * exp(x2);
int place[2] = {1, 2}; out(1, 0, place, data);
}
void Multiplication2(int tag, float x1, float x2)
{
float data[2];
data[0] = x1;
data[1] = x1 * pow(x2, 3);
int place[2] = {1, 2}; out(1, 0, place, data);
}
void Multiplication3(int tag, float x1, float x2)
{
float data[2];
data[0] = x1;
data[1] = x1 * sqrt(x2);
int place[2] = {1, 2}; out(1, 0, place, data);
}
void Check(int tag, float x1, float x2, float x3, float x4, float x5)
{
float xnew = x1 + x2 - x3; if(fabs(xnew - x1) < x5)
{
float data[1] = {xnew}; int place[1] = {1}; out(2, 0, place, data);
}
else
{
float data[2] = {xnew, x5}; int place[2] = {1, 2}; out(1, 0, place, data);
}
}
void StartEval(int tag, float x1)
{
float data[1] = {x1};
int place[2] = {1}; out(1, 0, place, data);
}
void PrintResult(int tag, float x1)
{
fprint("Корень уравнения равен %f", x1);
}
√
void startup()
{
float data[5]; |
|
GenFloat(data[0], 100); |
// a |
GenFloat(data[1], 100); |
// b |
GenFloat(data[2], 100); |
// c |
GenFloat(data[3], 0.001); |
// eps |
GenFloat(data[4], 10); |
// x0 |
// Сгенерируем новый уникальный тег int tag = GenTag();
int place[5] = {1, 2, 3, 4, 5}; out(1, tag, place, data);
}
void GenFloat(float &x, float p)
{
x = (float) rand() / (float) RAND_MAX * p;
}
void Multiplication1(int tag, float x1, float x2)
{
float data[2];
data[0] = x1;
data[1] = x1 * exp(x2);
int place[2] = {1, 2}; out(1, tag, place, data);
}
void Multiplication2(int tag, float x1, float x2)
{
float data[2];
data[0] = x1;
data[1] = x1 * pow(x2, 3);
int place[2] = {1, 2}; out(1, tag, place, data);
}
void Multiplication3(int tag, float x1, float x2)
{
float data[2];
data[0] = x1;
data[1] = x1 * sqrt(x2);
int place[2] = {1, 2}; out(1, tag, place, data);
}
void CheckCond(int tag, float x1, float x2, float x3, float x4, float x5)
{
float xnew = x1 + x2 - x3; if(fabs(xnew - x1) < x5)
{
float data[1] = {xnew}; int place[1] = {1}; out(2, tag, place, data);
}
else
{
float data[2] = {xnew, x5}; int place[2] = {1, 2}; out(1, tag, place, data);
}
}
void StartEval(int tag, float x1)
{
float data[1] = {x1};
int place[2] = {1}; out(1, tag, place, data);
}
void PrintResult(int tag, float x1)
{
fprint("Корень уравнения (tag %d) равен %f", tag, x1);
}
(∑ )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
( )
void startup()
{
int data[1]; |
|
data[0] = rand(); |
// N |
int place[1] = {1};
out(1, 0, place, data);
}
void Generate(int tag, int x1)
{
int data[1];
int place[1] = {1};
for(int i = 0; i < x1; i++)
{
data[0] = rand(); write(1, 0, place, data);
}
}
void Multiplication(int tag, int x1, int x2)
{
int data[1] = {x1 * x2};
int place[1] = {1}; out(1, 0, place, data);
}
void Sum(int tag, int x1, int x2)
{
int place[1] = {1}; int data[1] = {x1};
for(int i = 1; i < x1; i++)
{
read(1, 0, place, &val); data[0] += val;
}
out(1, 0, place, data);
}
void PrintResult(int tag, float x1)
{
fprint("Скалярное произведение равно %d", x1);
}