Cod sursa(job #420737)

Utilizator tomikaBorbath Tamas tomika Data 20 martie 2010 14:11:21
Problema Schi Scor 55
Compilator fpc Status done
Runda Arhiva de probleme Marime 1.7 kb
{
        schi.pas
        
        Copyright 2010 Borbath Tamas <[email protected]>
        
        This program is free software; you can redistribute it and/or modify
        it under the terms of the GNU General Public License as published by
        the Free Software Foundation; either version 2 of the License, or
        (at your option) any later version.
        
        This program is distributed in the hope that it will be useful,
        but WITHOUT ANY WARRANTY; without even the implied warranty of
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        GNU General Public License for more details.
        
        You should have received a copy of the GNU General Public License
        along with this program; if not, write to the Free Software
        Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
        MA 02110-1301, USA.
}


program schi;

uses crt;
type    lista=^listaelem;
		listaelem=record
			        adat:integer;
					next:lista;
				end;
  
var f:text;
	i,seged,n:integer;
	p:lista;
	
	
procedure feldolgoz(count,ertek:integer);
	var k:integer;
		s,se:lista;
		
begin
	s:=p;
	for k:=1 to count-1 do s:=s^.next;
	new(se);
	se^.adat:=ertek;
	se^.next:=s^.next;
	s^.next:=se;
	//writeln(count:5,ertek:5);
end;
procedure kiir(a:lista);
var g:text;
	begin
		assign(g,'schi.out');
		rewrite(g);
		//writeln('A kiiratas itt kezdodik!!!');
		a:=a^.next;
		while a<>nil do
			begin
				writeln(g,a^.adat);
				a:=a^.next;
			end;
	//	writeln('A kiiratas itt er veget!!!');
	close(g);
	end;
BEGIN
	new(p);
	p^.adat:=666;
	p^.next:=nil;
	assign(f,'schi.in');
	reset(f);
	readln(f,n);
	for i:=1 to n do
		begin
			readln(f,seged);
			feldolgoz(seged,i);
		end;
		kiir(p);
END.