|
program conteggio;
uses crt,windos,giobe,TVision2;
const a:byte=1;
e:byte=2;
i:byte=3;
o:byte=4;
u:byte=5;
var t:text;
lettere,parole,inter,num,virgole,punti,puntivir,dpunti,dom,esc:longint;
vocali:array[1..5] of integer;
nome:string;
c:char;
procedure centra(rig:byte;s:string);
begin
gotoxy(40-(Length(s) div 2),rig);
write(s);
end;
begin
textbackground(0);
clrscr;
ViaCur;
TextColor(15);
textbackground(0);
centra(1,'Conta caratteri di file');
gotoxy(1,2);
write('Scrivi il nome del file: ');
ripcur;
read(nome);
Assign(t,nome);
reset(t);
repeat
read(t,c);
if (c='a') or (c='A') then
vocali[a]:=vocali[a]+1;
if (c='e') or (c='E') then
vocali[e]:=vocali[e]+1;
if (c='i') or (c='I') then
vocali[i]:=vocali[i]+1;
if (c='o') or (c='O') then
vocali[o]:=vocali[o]+1;
if (c='u') or (c='U') then
vocali[u]:=vocali[u]+1;
if (c=',') then
begin
inter:=inter+1;
virgole:=virgole+1;
end;
if c=';' then
begin
inter:=inter+1;
puntivir:=puntivir+1;
end;
if c='.' then
begin
inter:=inter+1;
punti:=punti+1;
end;
if c=':' then
begin
inter:=inter+1;
dpunti:=dpunti+1;
end;
if c='?' then
begin
inter:=inter+1;
dom:=dom+1;
end;
if c='!' then
begin
inter:=inter+1;
esc:=esc+1;
end;
if (c='1') or (c='2') or (c='3') or (c='4') or (c='5')
or (c='6') or (c='7') or (c='8') or (c='9') or (c='0') then
num:=num+1;
if c=' ' then
parole:=parole+1;
lettere:=lettere+1;
until eof(t);
close(t);
gotoxy(1,3);
textcolor(15);
textbackground(0);
write(lettere,' caratteri in tutto.');
gotoxy(1,4);
write(parole,' parole.');
gotoxy(1,5);
write(vocali[a]+vocali[e]+vocali[i]+vocali[o]+vocali[u],' vocali:');
gotoxy(5,6);
write(vocali[a],' vocali a ;');
gotoxy(5,7);
write(vocali[e],' vocali e ;');
gotoxy(5,8);
write(vocali[i],' vocali i ;');
gotoxy(5,9);
write(vocali[o],' vocali o ;');
gotoxy(5,10);
write(vocali[u],' vocali u .');
gotoxy(1,11);
write(inter,' segni di interpunzione:');
gotoxy(5,12);
write(punti,' punti ;');
gotoxy(5,13);
write(virgole,' virgole ;');
gotoxy(5,14);
write(puntivir,' punti e virgola ;');
gotoxy(5,15);
write(dpunti,' doppi punti ;');
gotoxy(5,16);
write(dom,' punti di domanda ;');
gotoxy(5,17);
write(esc,' punti esclamativi .');
gotoxy(1,18);
write(num,' numeri.');
readln;
readln
end.
|
|