Простой пример сортировки 2х упорядоченных массивов слиянием.
uses crt; var a,b,c:array[1..500] of integer; n,m,i,j,k:integer; begin clrscr; write('n=');readln(n); write('m=');readln(m); writeln('Massiv A:'); for i:=1 to n do begin a[i]:=2*i+1;{введем нечетные числа} write(a[i],' ');{введем четные числа} end; writeln; writeln('Massiv B:'); for i:=1 to m do begin b[i]:=2*i; write(b[i],' '); end; writeln; i:=1; j:=1; k:=1; {устанавливаем счётчики} while (i<=n) or (j<=m) do {пока не дошли до конца каждого из массивов} begin if (i<=n) and (j<=m) then {если оба массива ещё не закончились} begin if a[i]<b[j] then {то пишем в новый массив меньший из текущих элементов} begin c[k]:= a[i]; inc (i); {переходим к следующему элементу соответствующего массива} inc (k); {переходим к следующему элементу конечного массива} end else begin c[k]:= b[j]; inc (j); inc (k); end end else if j>m then {иначе один из массивов уже закончился} begin {и мы пишем из того, в котором ещё есть элементы} c[k]:= a[i]; inc (i); inc (k); end else if i>n then begin c[k]:= b[j]; inc (j); inc (k); end; end; writeln('Massiv C:'); for i:=1 to m+n do write(c[i],' '); readln end.
Earn up to $3500/month just by taking simple surveys online!
I tried one of those online survey sites about 4 months ago that say all you have to do is spend a couple of minutes filling out some surveys and you will be making hundreds a day..... YEAH RIGHT, I didn't make anything.
I joined 7 of these stupid websites and I actually tried filling out a couple of surveys on each site and they took forever then at the end they wanted me to buy things or I couldn't complete the survey.
These are complete scams so be aware!!! I couldn't believe they were even allowed to sell such bogus products.
Then about 2 weeks ago I was watching the news and they had some vice presidents and marketing managers of some major multi million dollar companies talking about a site that they personally work with to pay consumers for their opinion, A site that actually just wants the "average Joe's" honest opinion on products and services and is willing to pay big money to get them. for more information clik here: http://take-survey-and-get-money.info