1) The document contains procedures for adding and subtracting items to lists of goods in Ada programming language.
2) The dodaj procedure adds a new item to the list by finding the correct insertion point based on item code and inserting a new node.
3) The odejmij procedure subtracts the quantities of matching items in two lists by traversing one list and modifying quantities or removing nodes in the other list.
1) The document contains procedures for adding and subtracting items to lists of goods in Ada programming language.
2) The dodaj procedure adds a new item to the list by finding the correct insertion point based on item code and inserting a new node.
3) The odejmij procedure subtracts the quantities of matching items in two lists by traversing one list and modifying quantities or removing nodes in the other list.
Copyright:
Attribution Non-Commercial (BY-NC)
Available Formats
Download as RTF, PDF, TXT or read online from Scribd
1) The document contains procedures for adding and subtracting items to lists of goods in Ada programming language.
2) The dodaj procedure adds a new item to the list by finding the correct insertion point based on item code and inserting a new node.
3) The odejmij procedure subtracts the quantities of matching items in two lists by traversing one list and modifying quantities or removing nodes in the other list.
Copyright:
Attribution Non-Commercial (BY-NC)
Available Formats
Download as RTF, PDF, TXT or read online from Scribd
procedure dodaj(s:in out spis_towarow; t:in towar)is
pred:node_pointer:=null; succ:node_pointer:=s.head; begin while succ /= null and then t.kod_towaru > succ.dane.kod_towaru loop pred:=succ; succ:=succ.next; end loop; if succ /= null and then succ.dane.kod_towaru = t.kod_towaru then succ.dane.liczba_sztuk:=succ.dane.liczba_sztuk+t.liczba_sztuk; else if pred /= null then pred.next:=new node'(t, succ); else s.head:=new node'(t, succ); end if; end if; end dodaj;
procedure odejmij(s1:in out spis_towarow; s2:in spis_towarow)is
pred:node_pointer:=null; succ:node_pointer:=s1.head; aktualny:node_pointer:=s2.head; roznica:float:=0.0; begin while aktualny /= null loop while succ /= null and then aktualny.dane.kod_towaru /= succ.dane.kod_towaru loop pred:=succ; succ:=succ.next; end loop; if succ /= null then roznica:=succ.dane.liczba_sztuk-aktualny.dane.liczba_sztuk; if roznica<=0.0 then if pred /= null then pred.next:=succ.next; else s1.head:=succ.next; free(succ); end if; else succ.dane.liczba_sztuk:=roznica; end if; end if; aktualny:=aktualny.next; end loop; end odejmij; ------magazyn procedure dodaj(s:in out spis_towarow; t:in towar; i:in rplus)is pred:node_pointer:=null; succ:node_pointer:=s.head; begin while succ /= null and then t.kod_towaru > succ.dane.kod_towaru loop pred:=succ; succ:=succ.next; end loop; if pred /= null then pred.next:=new node'(t, i, succ); else s.head:=new node'(t, i, succ); end if; end dodaj;
procedure kompresuj(s:in out spis_towarow)is
p:node_pointer:=s.head; temp:node_pointer:=null; begin if p /= null then while p.next /= null loop if p.dane.kod_towaru = p.next.dane.kod_towaru then p.ilosc_sztuk:=p.ilosc_sztuk+p.next.ilosc_sztuk; temp:=p.next; p.next:=p.next.next; free(temp); else p:=p.next; end if; end loop; else put("spis jest pusty!"); end if; end kompresuj;