Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Program ex7;
- Uses Wincrt;
- Type
- tab = Array ['A'..'Z'] Of Integer;
- Var
- f1,f2: Text;
- compt: tab;
- Procedure creation (Var f1,f2:Text);
- Begin
- Assign (f1,'c:\bac\ex7\ftxt.txt');
- Assign (f2,'c:\bac\ex7\modified.txt');
- End;
- Procedure espace (Var ch:String);
- Begin
- While Pos(' ',ch)<>0 Do
- Delete (ch,Pos(' ',ch),1);
- If ch[1]=' ' Then
- Delete(ch,1,1);
- If ch[Length(ch)]=' ' Then
- Delete (ch,Length(ch),1);
- End;
- Procedure supp_esp (Var f1,f2:Text);
- Var
- ch: String;
- Begin
- Reset (f1);
- Rewrite (f2);
- While Not (Eof(f1)) Do
- Begin
- Readln (f1,ch);
- espace (ch);
- Writeln (f2,ch);
- End;
- Close (f1);
- Close (f2);
- End;
- Procedure majchaine (Var ch:String);
- Var
- i: Integer;
- Begin
- For i:=1 To Length(ch) Do
- ch[i] := Upcase(ch[i]);
- End;
- Procedure convmaj (Var f1,f2:Text);
- Var
- ch: String;
- Begin
- Reset (f2);
- Rewrite (f1);
- While Not (Eof(f2)) Do
- Begin
- Readln (f2,ch);
- majchaine (ch);
- Writeln (f1,ch);
- End;
- Close (f1);
- Close (f2);
- Erase (f2);
- End;
- Procedure comptable (Var t:tab;Var ch:String);
- Var
- i,l: Char;
- j: Integer;
- Begin
- For i:='A' To 'Z' Do
- t[i] := 0;
- For j:=1 To Length(ch) Do
- Begin
- l := ch[j];
- If l In ['A'..'Z'] Then
- t[l] := t[l]+1;
- End;
- End;
- Procedure comptage (Var f1,f2:Text;Var compt:tab);
- Var
- ch: String;
- i: Char;
- t: tab;
- Begin
- Reset (f1);
- For i:='A' To 'Z' Do
- compt[i] := 0;
- While Not (Eof(f1)) Do
- Begin
- Readln (f1,ch);
- comptable (t,ch);
- For i:='A' To 'Z' Do
- compt[i] := compt[i]+t[i];
- End;
- Close (f1);
- End;
- Procedure affiche (Var compt:tab);
- Var
- i: Char;
- Begin
- For i:='A' To 'Z' Do
- If compt[i] <> 0 Then
- Writeln(i, ' : ', compt[i] ,' fois');
- End;
- Begin
- creation (f1,f2);
- supp_esp (f1,f2);
- convmaj (f1,f2);
- comptage (f1,f2,compt);
- affiche (compt);
- End.
Add Comment
Please, Sign In to add comment