Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Program bac2014;
- Uses Wincrt;
- Type
- tab = Array [1..20,1..20] Of Integer;
- Var
- f: Text;
- t: tab;
- n: Integer;
- Procedure creation (Var f:Text);
- Begin
- Assign (f,'c:\bac\result.txt');
- End;
- Function premier (n:Integer): Boolean;
- Var
- r,i: Integer;
- Begin
- r := 0;
- For i:=1 To n Do
- If (n Mod i =0) Then
- r := r+1;
- premier := r=2;
- End;
- Procedure remplir (Var t:tab;Var n:Integer);
- Var
- i,j: Integer;
- Begin
- Repeat
- Writeln ('Saisir N: ');
- Readln (n);
- Until (4<n) And (n<20);
- Randomize;
- For i:=1 To n Do
- For j:=1 To n Do
- Repeat
- t[i,j]:=random (100);
- Until (t[i,j] In [2..99]) And (premier(t[i,j]));
- End;
- Function ligne (t:tab;i,j,n:Integer): String;
- Var
- test: Boolean;
- ch,ch1: String;
- Begin
- ch := '';
- Repeat
- test := t[i,j]>t[i,j+1];
- j := j+1;
- Until (test=False) Or (j+1=n);
- If test=False Then
- Begin
- j := 1;
- Repeat
- test := t[i,j]<t[i,j+1];
- j := j+1;
- Until (test=False) Or (j+1=n);
- End;
- If test Then
- For j:=1 To n Do
- Begin
- Str (t[i,j],ch1);
- ch := ch+ch1+'-';
- End;
- ligne := Copy(ch,1,Length(ch)-1);
- End;
- Function collone (t:tab;i,j,n:Integer): String;
- Var
- test: Boolean;
- ch,ch1: String;
- Begin
- ch := '';
- Repeat
- test := t[i,j]>t[i+1,j];
- i := i+1;
- Until (test=False) Or (i+1=n);
- If test=False Then
- Begin
- i := 1;
- Repeat
- test := t[i,j]<t[i+1,j];
- i := i+1;
- Until (test=False) Or (i+1=n);
- End;
- If test Then
- For i:=1 To n Do
- Begin
- Str (t[j,i],ch1);
- ch := ch+ch1+'-';
- End;
- collone := Copy(ch,1,Length(ch)-1);
- End;
- Procedure traitement (Var f:Text;t:tab;n:Integer);
- Var
- i,j: Integer;
- Begin
- rewrite (f);
- For i:=1 To n Do
- Begin
- If ligne (t,i,1,n)<>'' Then
- Writeln(f,'L',i,'*', ligne (t,i,1,n)) ;
- If collone (t,1,i,n)<>'' Then
- Writeln(f,'C',i,'*', collone (t,1,i,n)) ;
- End;
- close (f);
- End;
- Begin
- creation (f);
- remplir (t,n);
- traitement (f,t,n);
- End.
Add Comment
Please, Sign In to add comment