Cod sursa(job #309739)

Utilizator marta_diannaFII Filimon Marta Diana marta_dianna Data 1 mai 2009 00:01:26
Problema Cifra Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 1.05 kb
program p1;
type vect=array[1..1000] of integer;
var f,g:text;
    a:vect;
    i,n,m,x:integer;

function gata(a:vect):boolean;
var j:integer;
begin
     gata:=true;
     for j:=1 to n do
         if a[j]=0 then begin
                             gata:=false;
                             break;
                             end;
end;

begin
     assign(f,'circle.in');reset(f);
     assign(g,'circle.out');rewrite(g);
     readln(f,n,m);
     i:=1;
     while not gata(a) do
           begin
                x:=0;
                while x<m do
                      begin
                           if a[i]=0 then x:=x+1;
                           if x=m then begin
                                            write(g,i,' ');
                                            a[i]:=1;
                                      end;
                           i:=i+1;
                           if i=n+1 then i:=1;
                      end;
           end;
     for i:=1 to n do
         a[i]:=i;

     close(f);
     close(g);
end.