Make a Pascal program, if you input a sentence, that sentence must be converted to numeric
Example:
Input
------------------------------------
Berapa
------------------------------------
Output
------------------------------------
b 2
e 5
r 18
a 1
p 16
a 1
------------------------------------
OK... i must tell you about this problem, you must learn array first
if you learned array several times ago.. let's continue
-------------------------------------------------------------
Try to read this code carefully.. you can copy it into pascal and compile it...
-------------------------------------------------------------
var
a : array[1..1000] of string;
s : array['a'..'z'] of byte = (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26);
b : array[1..1000] of integer;
i : integer;
u : char;
n : string;
begin
write('input string : '); readln(n);
for i := 1 to length(n) do
begin
a[i] := copy(n,i,1);
end;
for i := 1 to length(n) do
begin
for u := 'a' to 'z' do
begin
if (a[i] = u) then
begin
write(a[i],' ');
writeln(s[u],' ');
end;
end;
end;
readln;
end.
--------------------------------------------------------------------
There are many characters in input variable.. we must brake it into one character per variable
--------------------------------------------------------------------
write('input string: '); readln(n);
for i := 1 to length(n) do
begin
a[i] := copy(n,i,1);
end;
---------------------------------------------------------------------
Then, do the process of alphabetic konvert to numeric
---------------------------------------------------------------------
for i := 1 to length(n) do
begin
for u := 'a' to 'z' do
begin
if (a[i] = u) then
--------------------------------------------------------------------
Then, make a confirmation code.. if it is OK.. save it into array variable
--------------------------------------------------------------------
if (a[i] = u) then
begin
write(a[i],' ');
writeln(s[u],' ');
--------------------------------------------------------------------
Jam
Menu Software
Computer English
Link
Menu Blog
Promotion Blogs
ShoutBox
Welcome Word
Selamat Datang Di Blog ini...
Kalendar
Blog Archive
Sabtu, 16 Januari 2010
Posted in | |
0 Comments »
Breaking News
Mengenai Saya
- Rumah Info
- Bekasi Jaya, Jawa Barat, Indonesia
- saya sudah bersahabat dengan internet beberapa tahun silam
One Responses to "Pascal : Konversi huruf ke angka"