СДЕЛАЙТЕ ТРАССИРОВОЧНУЮ ТАБЛИЦУ #include
#include
using namespace std;
int ves, rost, vozrast, ideal, different, k;
string pol, otvet;
void Inform()//введение информации о себе
{
cout<<"vvedite svoi pol, man or woman"< >pol;
cout<<"vvedite svoi rost"< >rost;
cout<<"vvedite svoi vozrast"< >vozrast;
}
void Gender()//вычисление идеального веса
{
if (pol=="man") k=1;
if (pol=="woman") k=2;
switch (k)
{
case 1 :
ideal=1.15*(rost-110);
if (vozrast<=16) ideal=ideal-5;
if (vozrast>16 && vozrast<=25) ideal=ideal;
if (vozrast>25 && vozrast<=45) ideal=ideal+5;
if (vozrast>45) ideal=ideal-5;
cout<<"vash idealni ves="< >otvet;
break;
case 2 :
ideal=1.15*(rost-120);
if (vozrast<=16) ideal=ideal-5;
if (vozrast>16 && vozrast<=25) ideal=ideal;
if (vozrast>25 && vozrast<=45) ideal=ideal+5;
if (vozrast>45) ideal=ideal-5;
cout<<"vash idealni ves="< >otvet;
break;
default: cout<<"ne pravilniy pol"< >ves;
if(ves>ideal)
{
different=ves-ideal;
if (different>7)
cout<<"vash ves previshaet normu chtoby vash ves soblyudal normu zanimaytes' sportom yesh'te frukty i ovoshchi"< 7)
cout<<"vash ves nizhe normu chtoby vash soblyudal normu zanimaytes' sportom yesh'te frukty i ovoshchi"< else
cout<<"Vash ves sobludaet normu"< }
}
int main()
{
Inform();
Gender();
if (otvet=="yes")
{
Different();
}
return 0;
}
begin
var a:array[1..20] of integer;
Randomize;
for var i:=1 to 20 do a[i]:=Random(-50,50); a.Println;
var b:=Range(2,20,2).Select(i->a[i]);
Writeln('Элементы с четными индексами по возрастанию');
b.Sorted.Println;
Writeln('Элементы с четными индексами по убыванию');
b.SortedDescending.Println;
end.
Тестовое решение:
-15 46 -34 -3 43 16 -17 -28 -19 12 -28 -11 48 -12 -1 33 -37 9 6 -40
Элементы с четными индексами по возрастанию
-40 -28 -12 -11 -3 9 12 16 33 46
Элементы с четными индексами по убыванию
46 33 16 12 9 -3 -11 -12 -28 -40