Jumat, 02 Maret 2012

menghutung huruf array (pascal)


uses crt;

var n:array[1..26] of integer;

i,j:integer;

kata : String;

begin

writeln('=================================================');

writeln('');

for i:=1 to 26 do n[i]:=0;

write('Ketikkan sebuah kalimat : ');readln(kata);

writeln('');

writeln('Jumlah tiap huruf dlm kalimat :');

writeln('=============================');

for i:=1 to length(kata) do

for j:=1 to 26 do

if ord(upcase(kata[i]))=64+j then

inc(n[j]);

for i:=1 to 13 do

writeln(chr(64+2*i-1),' = ',n[2*i-1],' ',chr(64+2*i),'=',n[2*i]);

writeln('=============================');

readln;
end.

Tidak ada komentar:

Posting Komentar