Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {A program that can find all combinations possible with n integer}
- Program exercice;
- uses wincrt;
- Var
- f:text;
- n:integer;
- procedure creation (var f:text);
- Begin
- assign (f,'c:\bac\combianaison.txt');
- end;
- procedure saisie (var n:integer);
- Begin
- Repeat
- write ('Saisir N: ');
- readln (n);
- Until n in [1..100] ;
- end;
- function nettoyage (ch:string):string;
- Begin
- while (ch[1]='0') Do
- Begin
- delete (ch,1,1);
- end;
- nettoyage:=ch;
- end;
- procedure traitement (var f:text;n:integer);
- Var
- ch,ch1,c:string;
- aux:char;
- i:integer;
- Begin
- ch:='';
- for i:=n-1 downto 0 Do
- Begin
- str (i,c);
- ch:=ch+c;
- end;
- ch1:=ch;
- rewrite (f);
- i:=0;
- Repeat
- i:=i+1;
- aux:=ch1[i];
- ch1[i]:=ch1[i+1];
- ch1[i+1]:=aux;
- writeln (f,nettoyage (ch1));
- if (i+1=Length(ch)) Then
- i:=0;
- Until (ch1=ch);
- close (f);
- end;
- procedure affiche (var f:text);
- Var
- ch:string;
- Begin
- reset (f);
- while not (eof(f)) Do
- Begin
- readln (f,ch);
- writeln (ch);
- end;
- close (f);
- end;
- Begin
- creation (f);
- saisie (n);
- traitement (f,n);
- affiche (f);
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement