A.快速排序:procedure qsort(l,r:integer);var i,j,mid:integer;begini:=l;j:=r; mid:=a[(l+r) div 2]; {將當前序列在中間位置的數定義為中間數}repeatwhile a[i]<mid do inc(i); {在左半部分尋找比中間數大的數}while a[j]>mid do dec(j);{在右半部分尋找比中間數小的數}if i<=j then begin
高精度數的定義:typehp=array[1..maxlen] of integer; 1.高精度加法procedure plus ( a,b:hp; var c:hp);var i,len:integer;beginfillchar(c,sizeof(c),0);if a[0]>b[0] then len:=a[0] else len:=b[0];for i:=1 to len do begininc(c[i],a[i]+b[i]);if c[i]>10 then begin
1.已知前序中序求後序procedure Solve(pre,mid:string);var i:integer;beginif (pre='''') or (mid='''') then exit;i:=pos(pre[1],mid);solve(copy(pre,2,i),copy(mid,1,i-1));solve(copy(pre,i+1,length(pre)-i),copy(mid,i+1,length(mid)-i));post:=post+pre[1];
# include <stdio.h> # include <stdlib.h> # include <unistd.h> # include <sys/stat.h> # include <sys/mman.h> # include <sys/soundcard.h> # include <sys/ioctl.h> # include <sys/fcntl.h> #
七進位轉換1.任意正整數進位間的互化除n取餘2.實數任意正整數進位間的互化乘n取整3.負數進位:設計一個程式,讀入一個十進位數的基數和一個負進位數的基數,並將此十進位數轉換為此負進位下的數:-R∈{-2,-3,-4,....-20}八全排列與組合的產生1.排列的產生:(1..n)procedure solve(dep:integer);vari:integer;beginif dep=n+1 then begin writeln(s);exit; end;for i:=1 to n doif