Вариант 18. Вывести на печать таблицу n значений функции при изменении x от x1 до x2 с шагом h = (x2 – x1)/(n - 1). Коэффициенты a, b, c, границы интервала x1, x2 и число n ввести с клавиатуры.
Примерный код я уже составил, но я не понимаю как сделать чтоб прога мне таблицу строила.
вот мой код проги.
uses crt;
var a,b,c,n,h,y,
x,x1,x2: real;
begin
writeln (' введите число a');
readln (a);
writeln (' введите число b');
readln (b);
writeln (' введите число c');
readln (c);
writeln (' введите число x1');
readln (x1);
writeln (' введите число x2');
readln (x2);
writeln (' введите число n');
readln (n);
begin
x:=x1;
n:=n+1;
y:=sqrt(abs( a*(x*x)+b*x+c));
writeln ('y: ', y);
h:=(x2-x1)/(n-1);
writeln ('h: ',h);
repeat
x:=x1+h;
until h>=x2;
writeln ('n: ',n);
end;
end.
Другие языки программирования и технологии
Помогите составить кодпрограммы на pascal
Ну, во-первых нужно перенести внутрь цикла эти операторы:
n:=n+1;
y:=sqrt(abs( a*(x*x)+b*x+c));
writeln ('y: ', y);
Далее, выводить нужно не только y но и х. И еще эти операторы должны быть такими:
x:=x+h;
until х>=x2;
Ну и еще формат вывода - для вещественных чисел.
n:=n+1;
y:=sqrt(abs( a*(x*x)+b*x+c));
writeln ('y: ', y);
Далее, выводить нужно не только y но и х. И еще эти операторы должны быть такими:
x:=x+h;
until х>=x2;
Ну и еще формат вывода - для вещественных чисел.
Вот пример вывода в виде таблички
uses crt;
const p=2;m:array[1..p] of string[4]=('X','Y(x)');
var i,w,st:byte;
var x1,x2:real;
procedure Top;
var i,j:byte;
begin
write(#201);
for i:=1 to p do begin
for j:=1 to w do write(#205);
if i < p then write(#209)else write(#187);
end;
writeln;
write(#186);
for i:=1 to p do begin
for j:=1 to w do write(' ');
if i < p then write(#179)else write(#186);
end;
writeln;
gotoXY(1,whereY-1);
for i:=1 to p do begin
gotoXY(w*(i-1)+w div 2+i+1,whereY);
write(m[ i]);
end;
gotoXY(1,whereY+1);
write(#199);
for i:=1 to p do begin
for j:=1 to w do write(#196);
if i < p then write(#179)else write(#182);
end;
writeln;
end;
procedure Line;
var i,j:byte;
begin
write(#200);
for i:=1 to p do begin
for j:=1 to w do write(#205);
if i < p then write(#207)else write(#188);
end;
writeln;
end;
var x,y,dx:real;n:integer;
begin
clrscr;
writeln('Parameters of the table:');
st:=18;{The number of rows}
w:=15;{The column width}
x1:=-10;x2:=10;{x between -10 and 10}
clrscr;
Top;
dx:=0.3;
n:=0;
x:=x1-dx;
while x+dx <=x2 do begin
x:=x+dx;
y:=(3-x)/(x-1);
writeln(#186,x:w-1:1,' ',#179,y:w-1:3,' ',#186);
n:=n+1;
if n mod st=0 then begin
Line;{closing table}
write('Press ENTER to continue..');
readln;
clrscr;
Top;{Draw top of the table}
end
else if (x+dx >=x2) then begin
Line;{Close the table prematurely}
write('Press ENTER to exit');
readln;
end;
end;
end.
uses crt;
const p=2;m:array[1..p] of string[4]=('X','Y(x)');
var i,w,st:byte;
var x1,x2:real;
procedure Top;
var i,j:byte;
begin
write(#201);
for i:=1 to p do begin
for j:=1 to w do write(#205);
if i < p then write(#209)else write(#187);
end;
writeln;
write(#186);
for i:=1 to p do begin
for j:=1 to w do write(' ');
if i < p then write(#179)else write(#186);
end;
writeln;
gotoXY(1,whereY-1);
for i:=1 to p do begin
gotoXY(w*(i-1)+w div 2+i+1,whereY);
write(m[ i]);
end;
gotoXY(1,whereY+1);
write(#199);
for i:=1 to p do begin
for j:=1 to w do write(#196);
if i < p then write(#179)else write(#182);
end;
writeln;
end;
procedure Line;
var i,j:byte;
begin
write(#200);
for i:=1 to p do begin
for j:=1 to w do write(#205);
if i < p then write(#207)else write(#188);
end;
writeln;
end;
var x,y,dx:real;n:integer;
begin
clrscr;
writeln('Parameters of the table:');
st:=18;{The number of rows}
w:=15;{The column width}
x1:=-10;x2:=10;{x between -10 and 10}
clrscr;
Top;
dx:=0.3;
n:=0;
x:=x1-dx;
while x+dx <=x2 do begin
x:=x+dx;
y:=(3-x)/(x-1);
writeln(#186,x:w-1:1,' ',#179,y:w-1:3,' ',#186);
n:=n+1;
if n mod st=0 then begin
Line;{closing table}
write('Press ENTER to continue..');
readln;
clrscr;
Top;{Draw top of the table}
end
else if (x+dx >=x2) then begin
Line;{Close the table prematurely}
write('Press ENTER to exit');
readln;
end;
end;
end.
Похожие вопросы
- Помогите составить программу на pascal
- Помогите составить задачу в Pascal
- Помогите составить программу в pascal? срочно надо!!!!
- Помогите составить программу на Pascal.
- Помогите составить программу в Pascal ABC
- Помогите составить программу в Pascal или С++(а лучше и там и там)
- Помогите составить задачу на Pascal или С++
- Помогите составить программу в Pascal
- Помогите составить программу в Pascal
- помогите составить программу на Pascal дана матрица NxN.Найти наибольший элемент строки K.