|
|
|
Ngoài một số quy định đã được nêu trong phần Quy định của Ghi Danh , mọi người tranh thủ bỏ ra 5 phút để đọc thêm một số Quy định sau để khỏi bị treo nick ở MathScope nhé ! * Quy định về việc viết bài trong diễn đàn MathScope * Nếu bạn muốn gia nhập đội ngũ BQT thì vui lòng tham gia tại đây |
| Ðiều Chỉnh | Xếp Bài |
24-01-2013, 05:38 PM | #1 |
+Thành Viên+ Tham gia ngày: Jul 2012 Bài gởi: 103 Thanks: 259 Thanked 68 Times in 32 Posts | Lỗi tràn stack trong Free Pascal Anh chị em nào pro về tin học có thể chỉ giúp em vì sao code của chương trình này lại bị tràn stack không ạ : Code: program going_one_going_twice_gone; const max=1001; fi='cow.inp'; fo='cow.out'; type m1=array[0..max] of longint; var a:m1; m,n : integer; f:text; ok:m2; max_cost,tong_max:longint; procedure input; var i : integer; begin assign(f,fi); reset(f); readln(f,n,m); for i:=1 to m do readln(f,a[i]); close(f); end; procedure sort(l,r : integer); var i,j,tg,x : integer; begin x:=a[(l+r) div 2]; i:=l; j:=r; repeat while (a[i]<x) do inc(i); while (a[j]>x) do dec(j); if i<=j then begin tg:=a[i]; a[i]:=a[j]; a[j]:=tg; inc(i); dec(j); end; until i>j; if l<j then sort(l,j); if i<r then sort(i,r); end; procedure xuly_chinh; var i,j,k:integer; begin assign(f,fo); rewrite(f); sort(1,m); fillchar(ok,sizeof(ok),false); i:=m+2; a[m+1]:=0; a[m+2]:=0; a[0]:=0; max_cost:=0; tong_max:=0; while a[i]+a[i-1]<=a[i]*m do begin dec(i,2); max_cost:=a[i]; tong_max:=max_cost*(m-i+1); end; write(f,max_cost,' ',tong_max); close(f); end; begin input; xuly_chinh; end. Code: dec(i,2) |
24-01-2013, 10:20 PM | #2 | |
+Thành Viên+ | Trích:
Code: i:=m+2; | |
Bookmarks |
Ðiều Chỉnh | |
Xếp Bài | |
|
|