【问题标题】:how to make a function that prints a variable number of parameters in pascal?如何制作一个在帕斯卡中打印可变数量参数的函数?
【发布时间】:2014-03-25 18:30:36
【问题描述】:

我想让用户给我可变数量的字符串(作为病毒)。 示例:

开始 cout('Hello').('').('world') 结束。

这将打印:“Hello world” 我知道我只能让他输入一个字符串,但我想让这段代码工作...... 我认为记录会有所帮助,我不知道如何 谢谢

【问题讨论】:

  • 根据方言,在您的手册中搜索“array of const”

标签: variables parameters numbers pascal


【解决方案1】:

我不确定您编写的代码示例是什么……但我会尽力帮助您。

    Program test;
uses crt;

var string1,string2,string3:string;


begin
 write("Write to first string : "); readln(string1);
 write("Write to second string: "); readln(string2);
 write("Write to third string : "); readln(string3);

String2:= string1 +" "+ string3; // it will add first with third string to one with one space

String3:= string2 +" "+ string1;// also 2.+ 1.
clrscr; //clearscreen (in CRT)
writeln("1. = 1.");
writeln("2. = 1. + 3.");
writeln("3. = 2. + 1.");
writeln;
writeln(string1);
writelm(string2);
writeln(string3);

我还没有测试过这个(我现在已经为你写了)我想你会阅读它并学习如何上瘾或如何使用字符串做简单的事情。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-12-28
    • 2021-01-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多