Const x0=-10; xk=13; h=0.5; var x,y:real; i,n:integer; begin n:=round((xk-x0)/h)+1; x:=x0-h; for i:=1 to n do begin x:=x+h; if x<>7 then begin y:=(x*x*x+5*x-8)/(x-7); writeln(x:5:1,' ',y:8:3); end else writeln(x:5:1,' функция не определена'); end; end.
Basic: DIM tetradCount as INTEGER, oblojCount as INTEGER, price1 AS INTEGER, price2 AS INTEGER CLS INPUT "Введите кол-во тетрадей:"; tetradCount INPUT "Введите кол-во обложек:"; oblojCount
var x,y:real; i,n:integer;
begin
n:=round((xk-x0)/h)+1;
x:=x0-h;
for i:=1 to n do
begin
x:=x+h;
if x<>7
then begin y:=(x*x*x+5*x-8)/(x-7); writeln(x:5:1,' ',y:8:3); end
else writeln(x:5:1,' функция не определена');
end;
end.
Результат (для h=1.0):
-10.0 62.235
-9.0 48.875
-8.0 37.333
-7.0 27.571
-6.0 19.538
-5.0 13.167
-4.0 8.364
-3.0 5.000
-2.0 2.889
-1.0 1.750
0.0 1.143
1.0 0.333
2.0 -2.000
3.0 -8.500
4.0 -25.333
5.0 -71.000
6.0 -238.000
7.0 функция не определена
8.0 544.000
9.0 383.000
10.0 347.333
11.0 344.500
12.0 356.000
13.0 375.667
DIM tetradCount as INTEGER, oblojCount as INTEGER, price1 AS INTEGER, price2 AS INTEGER
CLS
INPUT "Введите кол-во тетрадей:"; tetradCount
INPUT "Введите кол-во обложек:"; oblojCount
price1 = tetradCount * 5
price2 = oblojCount * 3
PRINT "Стоимость тетрадей:"; price1
PRINT "Стоимость обложек:"; price2
PRINT "Общая стоимость:"; price1 + price2
END
C#:
Обычный класс, единственная директива препроцессора System, в методе main
int tetradCount, oblojCoubt, priceOne, priceTwo, priceSum;
Console.WriteLine("Введите кол-во тетрадей:");
tetradCount = int.Parse(Console.ReadLine());
Console.WriteLine("Введите кол-во обложек:");
oblojCount = int.Parse(Console.ReadLine());
priceOne = tetradCount * 5;
priceTwo = oblojCount * 3;
priceSum = priceOne + PriceTwo;
Console.WriteLine("Стоимость тетрадей: " + priceOne);
Console.WriteLine("Стоимость обложек: " + priceTwo);
Console.WriteLine("Общая стоимость: " + priceSum);