如何在Pascal中使用具有不同数据类型的多个参数来实现功能?

Wid*_*oud 0 pascal freepascal

我已经用两个具有相同数据类型的参数制作了一个函数,对此我没有任何问题。

但是我在使用不同的数据类型时遇到了麻烦

这是我的代码:

uses crt;
function inputscore(name : string, score:integer) : integer;

begin
     writeln('My name is ',name,' and my score is ',score);
     inputscore:=0;
end;

begin
    clrscr;

    inputscore('David',98);
    readkey;
end.
Run Code Online (Sandbox Code Playgroud)

但是它返回了此错误消息:

multipleparameterfunc.pas(2,34)Fatal syntax error, ")" expected but "," found

Wos*_*osi 5

在Pascal中,您可以使用来分隔参数;。因此,您的定义必须如下所示:

function inputscore(name: string; score: integer) : integer;
Run Code Online (Sandbox Code Playgroud)

当您调用该函数时,仍然可以使用a ,分隔参数:

inputscore('David', 98);
Run Code Online (Sandbox Code Playgroud)