===== C++ 17 =====
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int nm = 12, nd = 28;
float t2009[12][28], t2010[12][28], pt[12][28];
float dT[nm][2] ={{-7.3,-4},{-9.8, -9.1},{-4.4, 2.6},{2.2,11.3},
{7.7,18.6},{12.1,22},{14.4,24.3},{12.5,21.9},
{7.4,15.7},{2.2,8.7},{-3.3,0.9},{-7.6,-3}};
srand(time(NULL));
for(int m = 0; m < nm; m++)
float k = (dT[m][1] - dT[m][0])/RAND_MAX;
for(int d =0; d < nd; d++)
t2009[m][d] = rand() * k + dT[m][0];
t2010[m][d] = rand() * k + dT[m][0];
pt[m][d] = t2010[m][d] / t2009[m][d] * 100;
}
cout << "2009\n";
cout << fixed << setw(5) << setprecision(1) << t2009[m][d];
cout << endl;
cout << "2010\n";
cout << fixed << setw(5) << setprecision(1) << t2010[m][d];
cout << "PERCENTS\n";
cout << fixed << setw(5) << setprecision(0) << pt[m][d];
return 0;
===== PascalABC.NET =====
type
Vector = array of real;
function operator +(a, b: Vector): Vector;
ExtensionMethod := a.Zip(b, (p, q) -> p + q).ToArray;
function operator -(a, b: Vector): Vector;
ExtensionMethod := a.Zip(b, (p, q) -> p - q).ToArray;
function operator *(s: real; a:Vector): Vector;
ExtensionMethod := a.ConvertAll(p -> p * s);
begin
var a: Vector := ReadArrReal('Вектор a:', 3);
var b: Vector := ReadArrReal('Вектор b:', 3);
var c: Vector := ReadArrReal('Вектор c:', 3);
var k := ReadReal('k =');
Println(k * (a + b) + (1 - k) * (a + c))
end.
===== C++ 17 =====
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int nm = 12, nd = 28;
float t2009[12][28], t2010[12][28], pt[12][28];
float dT[nm][2] ={{-7.3,-4},{-9.8, -9.1},{-4.4, 2.6},{2.2,11.3},
{7.7,18.6},{12.1,22},{14.4,24.3},{12.5,21.9},
{7.4,15.7},{2.2,8.7},{-3.3,0.9},{-7.6,-3}};
srand(time(NULL));
for(int m = 0; m < nm; m++)
{
float k = (dT[m][1] - dT[m][0])/RAND_MAX;
for(int d =0; d < nd; d++)
{
t2009[m][d] = rand() * k + dT[m][0];
t2010[m][d] = rand() * k + dT[m][0];
pt[m][d] = t2010[m][d] / t2009[m][d] * 100;
}
}
cout << "2009\n";
for(int m = 0; m < nm; m++)
{
for(int d =0; d < nd; d++)
cout << fixed << setw(5) << setprecision(1) << t2009[m][d];
cout << endl;
}
cout << "2010\n";
for(int m = 0; m < nm; m++)
{
for(int d =0; d < nd; d++)
cout << fixed << setw(5) << setprecision(1) << t2010[m][d];
cout << endl;
}
cout << "PERCENTS\n";
for(int m = 0; m < nm; m++)
{
for(int d =0; d < nd; d++)
cout << fixed << setw(5) << setprecision(0) << pt[m][d];
cout << endl;
}
return 0;
}
===== PascalABC.NET =====
type
Vector = array of real;
function operator +(a, b: Vector): Vector;
ExtensionMethod := a.Zip(b, (p, q) -> p + q).ToArray;
function operator -(a, b: Vector): Vector;
ExtensionMethod := a.Zip(b, (p, q) -> p - q).ToArray;
function operator *(s: real; a:Vector): Vector;
ExtensionMethod := a.ConvertAll(p -> p * s);
begin
var a: Vector := ReadArrReal('Вектор a:', 3);
var b: Vector := ReadArrReal('Вектор b:', 3);
var c: Vector := ReadArrReal('Вектор c:', 3);
var k := ReadReal('k =');
Println(k * (a + b) + (1 - k) * (a + c))
end.