var n:longint; s:string;begin readln(n);str(n,s);writeln(s);end.
基本数据类型(常用) 整数类型:Integer 实数类型:Double 字符类型:Char 字符串类型:String 布尔类型:Boolean 数据类型转换 inttostr(x) 将字符串x转换成int,前提是x为数值型字符串 相应的还有:strtoint(x)、floattostr(x)、strtofloat(x) 运算符(需注意的) 1、算术运算符: +、-、* 等运算符和 C 语言相应的...
integer整形 longint长整形,比integer大 real实形 string字符串形 Boolean布尔型 const:定义常量标志 var定义变量标志 type定义类型标志
例如:var name:string; begin readln(nsme); for i:=1 to ord(name0) do writeln(namei);end. 语句writeln(namei)输出name串中第i个字符。 【例2】求输入英文句子单词的平均长度程序如下:program ex8_2; var ch:s 5、tring; s,count,j:integer; begin write('The sentence is :'); readln(ch); ...
function Add(a, b: Integer): Integer; begin Add := a + b; end; ``` ### 过程示例 ```pascal procedure PrintMessage(message: String); begin WriteLn(message); end; ``` ## 5. 输入与输出 Pascal提供了丰富的输入输出例程。 ### 输出 使用`Write`和`WriteLn`进行输出。 ```pascal Write...
s:string;t:integer;begin readln(s); t:=s[3]: s[3]:=s[1]; s[1]:=t; writeln(s);end.第二题: var i,n:integer;begin readln(n); if(nmod100=0)and(nmod400=0)thenwriteln('yes'); if(nmod100=0)and(nmod400<>0)thenwriteln('no'); if(nmod100<>0)and(nmod4=0)then...
1、PASCAL常用的字符串函数求长度length定义:function Length(S: String): Integer;复制子串copy定义: function Copy(S: String; Index: Integer; Count: Integer): String;注意:S 是字符串类型的表达式。Index和Count是整型表达式。Copy 返回S中从Index开始,Count个字符长的一个子串。例子:var S: String;beginS...
procedure count(s:string,n:integer);var a,b,i:integer;begin a:=0;b:=0;i:=1;repeat i := i + 1;if s[i]=='W' then a:=a+1;if s[i]=='L' then b:=b+1;if ((a>=n) and (b>=n) and (abs(a-b)>=2)) or (s[i]=='E') then begin writeln(a+':'+b...
/* 将整型转换成字符(integer to ascii) */ static void itoa(unsigned int value, char** buf_ptr_addr, unsigned char base) { unsigned int m = value % base; // 求模,最先掉下来的是最低位 unsigned int i = value / base; // 取整 ...
i,len,li,u:Integer; l1:String; Label 100; Procedure stop; Begin Writeln('Input Error'); Readln; Halt; End; begin writeln; i:=0; l1:=''; l:=0; m:=0; li:=0; writeln('Input a Number (2<x<1499999999) '); readln(l1); len:=length(l1); If (len<1) or ...