Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program Project2;
- {$APPTYPE CONSOLE}
- uses
- SysUtils;
- var
- n, k, i, j, last, curindex, maxindex, curelem, counter, goodslen: Integer;
- sweets: array of Integer;
- goods: array of array [1..2] of Integer;
- amounts: array of Integer;
- begin
- Writeln('Enter');
- Read(n);
- Readln(k);
- Writeln;
- Write(n, ' ');
- Writeln(k);
- SetLength(Sweets, n);
- Last:= high(sweets);
- for i:= 0 to Last do
- Readln(sweets[i]);
- for i:= 0 to Last do
- Write(sweets[i], ' ');
- curindex:= 0;
- maxindex := last;
- curelem := -1;
- counter :=0 ;
- goodslen := 0;
- for i := 0 to last do
- begin
- curelem := sweets[i];
- if curelem <> 0 then
- begin
- SetLength(goods, goodslen + 1);
- Inc(goodslen);
- counter := 0;
- for j := i to last do
- if sweets[j] = curelem then
- begin
- Inc(Counter);
- sweets[j] := 0;
- end;
- goods[i][1] := curelem;
- goods[i][2] := counter;
- end;
- end;
- last := High(goods);
- Writeln('-----------------');
- Write('Type :');
- for i := 0 to last do
- Write(goods[i][1],' ');
- Writeln;
- Write('Amount:');
- for i := 0 to last do
- Write(goods[i][2],' ');
- SetLength(Amounts, Last + 1);
- for i := 0 to last do
- amounts[i] := goods[i][2] div k;
- Writeln;
- Writeln('Amounts:');
- for i := 0 to last do
- Write(amounts[i], ' ');
- Writeln;
- Writeln('Result');
- for i := 0 to last do
- for j := 1 to amounts[i] do
- Write(goods[i][1], ' ');
- Writeln('Fin');
- Readln;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement