首页 > 代码库 > Pascal ASCII和文本的转换
Pascal ASCII和文本的转换
用于帮助新手理解ASCII码和字符型与整型的一段小程序,转载请注明出处
例如:输入 I love you
打印 73 32 108 111 118 101 32 121 111 117 13 10
Program TransPro (input,output);
Var
judge,number:integer;
letter:char;
begin
writeln(‘This software was produced by Chaobs!‘);
writeln(‘You can use this software‘);
writeln(‘to translate numbers into letters or to translate to nuambers!‘);
writeln(‘Press 1 to transplate numbers and 2 to transplate letters‘);
read(judge);
IF judge=1
Then
Begin
Repeat
read(number);
letter:=chr(number);
write(letter);
Until number=33;
readln;
END;
IF judge=2
then
Begin
Repeat
read(letter);
number:=ord(letter);
write(number,‘ ‘);
UNTIL letter=‘!‘;
readln;
END;
writeln(‘If you foud something wrong with my program please call Chaobs!‘);
readln;
END.