... record key, infor: integer; end; var A: array[1 maxN] of diem; N: integer; procedure intialze; begin N:=0; end; function seqsearch(v: integer; x : integer): integer; begin A[N+1].key:=v; If x then ... z, dau: lienket; function timkiemcaynhiphan(k : integer; x : lienket): lienket; begin z ↑.khoa:= k; repeat if (k< x ↑.khoa) then x:= x ↑.l else x: = x↑.r; until k = x↑.khoa; timkiemcaynhiphan:= ... infor: integer; x: lienket); tương tự hàm chentrongcay, hàm gtchen đặt giá trị cho đối số vào trường infor; + Hàm gtxoăk, infor: integer ; x: lienket) dùng để xoá nút với khoá k số mảng infor...
... liệu vào file Meet.inp : - dòng đầu ghi số M,N - M dòng tiếp theo, dòng ghi N số mô tả trạng thái ô vuông: 1-có vật cản, 0-không có vật cản Các số dòng file liệu cách dấu trắng Kết ghi file Meet.out...
... thái xét} found:=false; While (P # y) and (not found) 2.1.Loại bỏ trạng thái u đỉnh stack P đặt vào hàng đợi Q: Pop(P,u); Ađ(u,Q); 2.2.if u=ut then found:= true else For v ẻ kề (u) if(v ẽ P U ... P; End; Output: Nếu found = false bàitoán lời giải Nếu found = true lời giải đường từu0 tới ut xác định cách sử dụng hàm father Chú ý:Saukhi chuyển trạng thái từ P vào P P= f h(v 1) ≤ h(v 2) ≤ ... else For v ẻ kề (u) if(v ẽ P U Q) and (h(v)
... kiemtra; case kt of : exit; : cmax:= ctg-1; : cmin:= ctg+1; end; end; end; procedure ghif; var f : text; begin assign (f, fo); rewrite (f) ; write (f, ctg); close (f) ; end; BEGIN docf; lam; ghif; END Bài tập ... n : integer; cmin, cmax, ctg: longint; procedure docf; var f : text; begin assign (f, fi); reset (f) ; readln (f, n); readln (f, s); close (f) ; end; function nhan(x:string; so: longint): string; var nho, ... 2; fillchar(dx,sizeof(dx),0); dem:=1; kq[1]:=x; ok:= false; di(x); if ok then cmin:= ctg+1 else cmin:= ctg-1; end; end; procedure ghif; var f : text; k : integer; begin assign (f, fo); rewrite (f) ;...
... rộng cần sửa lạinhư sau: Procedure Find; Begin Fillchar(Daxet,SizeOf(Daxet),False); Connect:=0; For u thuộc V If not Daxet[u] then Begin Inc(Connect); DFS(u); (* BFS(u) *) End; End; Thủ tục Visit(u)sẽ ... trước củav đường Khi đó, câu lệnh If thủ tục DFS(u) sửa lại nhưsau: if not Daxet[v] then Begin DFS(v); Truoc[v]:= u; End; Còn với thủ tụcBFS ta sửa lại lệnh If sau: If not Daxet[w]then Begin Kết nạp ... Kề(v) If not Daxet[w] then Begin Kết nạp w vàoQueue; Daxet[w]:=True; End; End; End; Ta có thủ tụctìm kiếm theo chiều rộng là: Procedure Find; Begin Fillchar(Daxet,SizeOf(Daxet),False); For u thuộc...
... thuậttoán sau : function Rabin_Karp(string T[1 n], string P[1 m]) hsub := hash(P[1 m]) // giá trị băm xâu P hs := hash(T[1 m]) // giá trị băm xâu T for i from to n-m+1 if hs = hsub if T[i i+m-1] ... T có k ký tự If m + i = k then - Thoát, trường hợp thỏa mãn Else - So sánh P[i] với T[m + i]: - If (bằng nhau) then i &lar;i+1 If i = n then ta tìm xâu T thỏa mãn vị trí m; - If (không nhau), ... (mismatch) F[ 1 m] giá trị F[ i] tổng số ký tự ta lùi lại để xét tiếp xâu T sau gặp vị trí sai xét đến ký tự thứ i xâu mẫu tìm kiếm Tức vị trí m mà T[m+i] khác P[i] ta xét tiếp vị trí m+i -F[ i] xâu...
... T f ( x | be 0)dx P1 f (T | be 1) P0 f (T | be 0) Các hàm f ( x | be 0) f ( x | be 1) đánh giá từ thống kê X X max tương ứng Qua thực nghiệm X X max , ta thấy phân phối f ( x ... Hiding” IBM SYSTEMS JOURNAL, VOL 35, NOS 3&4, 1996 [12] Stefan Katzenbeisser and Fabien A.P.Petitcolas, “Information Hiding Techniques for Steganography and Digital Watermarking”.Artech House Boston ... Ghafoor “Watermarking Relational Databases using Optimization Based Techniques” CERIAS Tech Report 2006-41 [10] www.watermarkingworld.org [11] W Bender, D Gruhl, N Morimoto, A Lu, “Techniques for...
... scanf("%d", &n); int* a = new int[n]; for (int i = 0; i < n; i++) { printf("Nhap a[%d]: ",i); scanf("%d", &a[i]); } int x; printf("Nhap gia tri phan tu can tim kiem: "); scanf("%d", &x); Biên dịch đoạn ... clock_t start, end; double cpu_time_used; start = clock(); /* Do the work */ end = clock(); cpu_time_used = ((double) (end - start)) / CLOCKS_PER_SEC; printf("Thoi gian xu ly la: %f\ n", ... giải thuật HCMUS 2010 Trang } int i = LinearExhaustive(a, n, x); if (i == -1){ printf("Khong tim thay x mang A\n"); } else{ printf("Vi tri x mang A la: %d\n", i + 1); //Tại lại xuất i+1 } return...
... toán} For i:=3 to 100 Begin s:=0 For j:=2 to i If i mod j = then Begin ngt:= True; If j >2 then {số số nguyên tố} For k:=2 to j-1 If j mod k = then ngt:= False; If ngt then s:=s+1; End; If s=2 ... Readln(a[i]); End; C:= False For i:=2 to 20 If (a[i] mod =0) and (a[i-1] mod = 1) then c:= True; If not c then For i:=1 to 20 If a[i] < then Write (a[i]:8) Else For i:=1 to 20 If a[i] > then Write ... Readln(M); S:=0; For i:=N to M Begin If i > then nt:= True Else nt:=False; {các số 0,1, số số nguyên tố, không cần kiểm tra} If i > then For j:=2 to i-1 If i mod j = then nt:= False; If nt then Begin...
... kt then begin timp (tim, spt); writeln (f, 'YES'); for k:=spt downto write (f ,tim[ k],' >'); write (f ,tim[ 1]); end else write (f, 'NO'); close (f) ; END File vào ví dụ: (EULER.INP) 45 12 34 File tương ứng: ... mang=array[1 max] of integer; var a:array[1 max,1 max] of integer; c ,tim: mang; n,m,spt,k:integer; f: text; procedure input; var i,x,y:integer; begin assign (f, 'Euler.inp');reset (f) ; readln (f, n,m); for i:=1 ... begin readln (f, x,y); a[x,y]:=1; a[y,x]:=1; end; close (f) ; end; function kt:boolean; var i,j,s,d:integer; begin d:=0; for i:=1 to n begin s:=0; for j:=1 to n if(ij) then s:=s+a[i,j]; if s mod 20...