Các vị bô lão xem giùm em bài này, test quài, riết rồi nó cứ lỗi như vầy là saooo!
Đề bài là:
Tính hàm Cosx theo chuỗi Taylor :
Nhập x hoặc không nhập gì vào bàn phím.
Đây là bài tập Pascal của học sinh cấp 3 ạ.
Hóng các cao nhân chỉ giáo a. Thăn kiu thăn kiu
program Bt1 ;
var n,x: integer ;
cosx : real ;
procedure gthua(var x : integer ; n:integer):real;
var tso,a ,b, i : integer;
Tong : real ;
begin
tso:=1;
a:=-1;
b:=1;
For i:= 1 to n do a:=a*(-1);
for i:= 1 to (2*n) do tso :=tso*x;
for i:= 1 to (2*n) do b:= 2*n*((2*n)-1);
Tong:=a*(tso/b);
end;
begin
writeln('Nhap x: ');
Readln(x);
n:=1;
while(gthua(n,x) >=0.00001) do
begin
cosx:= cosx + gthua(n,x) ;
n:= n+1 ;
end;
writeln('Ket qua la : ');
readln;
end.
Compiler Messages
bai1.pas(4,16) Error: overloaded identifier "gthua" isn't a function
bai1.pas(4,45) Error: Fields cannot appear after a method or property definition
bai1.pas(20,12) Fatal: Syntax error, ")" expected but "(" found
bai1.pas(0) Fatal: Compilation aborted
F1 Help F3 Open Alt+F9 Compile F9 Make Alt+F10 Local Menu