Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Contaparole - CONTAPAR.PAS

CONTAPAR.PAS

Caricato da: Totem
Scarica il programma completo

  1. program conteggio;
  2. uses crt,windos,giobe,TVision2;
  3. const a:byte=1;
  4.       e:byte=2;
  5.       i:byte=3;
  6.       o:byte=4;
  7.       u:byte=5;
  8. var t:text;
  9.     lettere,parole,inter,num,virgole,punti,puntivir,dpunti,dom,esc:longint;
  10.     vocali:array[1..5] of integer;
  11.     nome:string;
  12.     c:char;
  13.  
  14. procedure centra(rig:byte;s:string);
  15. begin
  16.     gotoxy(40-(Length(s) div 2),rig);
  17.     write(s);
  18. end;
  19.  
  20. begin
  21.     textbackground(0);
  22.     clrscr;
  23.     ViaCur;
  24.     TextColor(15);
  25.     textbackground(0);
  26.     centra(1,'Conta caratteri di file');
  27.     gotoxy(1,2);
  28.     write('Scrivi il nome del file: ');
  29.     ripcur;
  30.     read(nome);
  31.     Assign(t,nome);
  32.     reset(t);
  33.     repeat
  34.     read(t,c);
  35.     if (c='a') or (c='A') then
  36.       vocali[a]:=vocali[a]+1;
  37.     if (c='e') or (c='E') then
  38.       vocali[e]:=vocali[e]+1;
  39.     if (c='i') or (c='I') then
  40.       vocali[i]:=vocali[i]+1;
  41.     if (c='o') or (c='O') then
  42.       vocali[o]:=vocali[o]+1;
  43.     if (c='u') or (c='U') then
  44.       vocali[u]:=vocali[u]+1;
  45.     if (c=',') then
  46.       begin
  47.       inter:=inter+1;
  48.       virgole:=virgole+1;
  49.       end;
  50.     if c=';' then
  51.       begin
  52.       inter:=inter+1;
  53.       puntivir:=puntivir+1;
  54.       end;
  55.     if c='.' then
  56.       begin
  57.       inter:=inter+1;
  58.       punti:=punti+1;
  59.       end;
  60.     if c=':' then
  61.       begin
  62.       inter:=inter+1;
  63.       dpunti:=dpunti+1;
  64.       end;
  65.     if c='?' then
  66.       begin
  67.       inter:=inter+1;
  68.       dom:=dom+1;
  69.       end;
  70.     if c='!' then
  71.       begin
  72.       inter:=inter+1;
  73.       esc:=esc+1;
  74.       end;
  75.     if (c='1') or (c='2') or (c='3') or (c='4') or (c='5')
  76.     or (c='6') or (c='7') or (c='8') or (c='9') or (c='0') then
  77.       num:=num+1;
  78.     if c=' ' then
  79.       parole:=parole+1;
  80.     lettere:=lettere+1;
  81.     until eof(t);
  82.     close(t);
  83.     gotoxy(1,3);
  84.     textcolor(15);
  85.     textbackground(0);
  86.     write(lettere,' caratteri in tutto.');
  87.     gotoxy(1,4);
  88.     write(parole,' parole.');
  89.     gotoxy(1,5);
  90.     write(vocali[a]+vocali[e]+vocali[i]+vocali[o]+vocali[u],' vocali:');
  91.     gotoxy(5,6);
  92.     write(vocali[a],' vocali a ;');
  93.     gotoxy(5,7);
  94.     write(vocali[e],' vocali e ;');
  95.     gotoxy(5,8);
  96.     write(vocali[i],' vocali i ;');
  97.     gotoxy(5,9);
  98.     write(vocali[o],' vocali o ;');
  99.     gotoxy(5,10);
  100.     write(vocali[u],' vocali u .');
  101.     gotoxy(1,11);
  102.     write(inter,' segni di interpunzione:');
  103.     gotoxy(5,12);
  104.     write(punti,' punti ;');
  105.     gotoxy(5,13);
  106.     write(virgole,' virgole ;');
  107.     gotoxy(5,14);
  108.     write(puntivir,' punti e virgola ;');
  109.     gotoxy(5,15);
  110.     write(dpunti,' doppi punti ;');
  111.     gotoxy(5,16);
  112.     write(dom,' punti di domanda ;');
  113.     gotoxy(5,17);
  114.     write(esc,' punti esclamativi .');
  115.     gotoxy(1,18);
  116.     write(num,' numeri.');
  117.     readln;
  118.     readln
  119. end.