pascal笑话大集合,吧友速速前来,要么笑掉大牙,要么来发笑话!
pascal吧
全部回复
仅看楼主
level 8
徐一凡_exe 楼主
有一道题:
输入一个字符串(长度可能无限),在下一行输出其中的数字。
学渣用string,没得满分。(长度不够)
正常人用ansistring,没得满分。(还是长度不够)
学霸用pchar,没得满分。(内存爆了)
学神用链表,没得满分。(还是内存爆了)
屌丝用not eoln,得了满分。
从这个故事,我知道了一个道理:原来我就是屌丝。[酷]
2015年09月27日 07点09分 1
level 8
徐一凡_exe 楼主
你们也可以吐槽!
2015年09月27日 07点09分 2
高手直接用uses,发现某个单元有这个procedure。
2015年10月02日 09点10分
level 11
不懂……
2015年09月27日 13点09分 3
level 3
pchar是什么
2015年09月27日 13点09分 4
劈叉[酷]
2015年10月04日 10点10分
level 8
你个水比[阴险]
2015年09月27日 14点09分 5
level 14
让我想起a+b:
最简洁的解法:
program p1000;
var a,b:longint;
begin
read(a,b);
writeln(a+b);
end.
高精度算法:
program p1000;
var
st:string;
x,y:array[0..101]of integer;
i,j,l1,l2:integer;
begin
readln(st);
fillchar(x,sizeof(x),0);
fillchar(y,sizeof(y),0);
l1:=length(st);
for i:=l1 downto 1 do
x[l1-i]:=ord(st[i])-ord('0');
readln(st);
l2:=length(st);
for j:=l2 downto 1 do
y[l2-j]:=ord(st[j])-ord('0');
if l1<l2 then l1:=l2;
for i:=0 to l1 do
begin
x[i]:=x[i]+y[i];
if x[i]>=10 then begin
inc(x[i+1]);
dec(x[i],10);
end;
end;
while x[l1]<>0 do
inc(l1);
for i:=l1-1 downto 0 do
write(x[i]);
end.
DP解法(先算‘A'再算‘B'):
program p1000;
var
a,b,i:int64;
s:int64;
begin
readln(a,b);
for i:=1 to a do inc(s);
for j:=1 to b do inc(s);
writeln(s);
end.
随机数Random算法:
program p1000;
var a,b,n,m,s:longint;
begin
readln(a,b);
randomize;
repeat
n:=random(a+1);
m:=random(b+1);
s:=random(n+m+1);
until s=a+b;
writeln(s);
end.
数形结合的算法(利用 直角三角形公式A^2+B^2=C^2):
program p1000;
var
a,b,c:longint;
begin
readln(a,b);
c:=sqr(sqr(sqrt(a))+sqr(sqrt(b)));
writeln(trunc(sqrt(c));
end.
最小网络流:
program p1000;
var
en,et,ec,eu,ep,ex:Array[0..250000] of longint;
dis:array[0..1000] of longint;
v:array[0..1000] of boolean;
i,j,k,n,m,w,cost,l:longint;
a,b,ans,left,right:longint;
function min(a,b:longint):longint;
begin
if a<b then min:=a else min:=b
end;
procedure addedge(s,t,c,u,k:longint);
begin
inc(l);
en[l]:=en[s];
en[s]:=l;
et[l]:=t;
ec[l]:=c;
eu[l]:=u;
ep[l]:=l+k;
end;
procedure build(s,t,u,c:longint);
begin
addedge(s,t,c,u,1);
addedge(t,s,-c,0,-1);
end;
function aug(no,m:longint):longint;
var
i,d:longint;
begin
if no=n then
begin
inc(cost,m*dis[1]);
exit;
end;
v[no]:=true;
i:=ex[no];
while i<>0 do
begin
if (eu[i]>0)and not v[et[i]] and(dis[et[i]]+ec[i]=dis[no]) then
begin
d:=aug(et[i],min(m,eu[i]));
if d>0 then
begin
dec(eu[i],d);
inc(eu[ep[i]],d);
ex[no]:=i;
exit(d);
end;
end;
i:=en[i];
end;
ex[no]:=i;
exit(0);
end;
function modlabel:boolean;
var
d,i,j:longint;
begin
d:=maxlongint;
for i:=1 to n do
if v[i] then
begin
j:=en[i];
while j<>0 do
begin
if (eu[j]>0)and not v[et[j]] and(ec[j]-dis[i]+dis[et[j]]<d) then
d:=ec[j]-dis[i]+dis[et[j]];
j:=en[j]
end;
end;
if d=maxlongint then exit(true);
for i:=1 to n do
if v[i] then
begin
v[i]:=false;
inc(dis[i],d);
end;
exit(false);
end;
function work:longint;
var i:longint;
begin
cost:=0;
repeat
for i:=1 to n do ex[i]:=en[i];
while aug(1,maxlongint)>0 do
fillchar(v,sizeof(v),0);
until modlabel;
work:=cost;
end;
function solve(x,d:longint):longint;
var i,k,t,p,last,cost,lk:longint;
begin
fillchar(en,sizeof(en),0);
fillchar(dis,sizeof(dis),0);
k:=0;
n:=2;
t:=x;
p:=0;
while x<>0 do
begin
k:=k+x mod 10;
x:=x div 10;
inc(p);
end;
n:=1;
x:=t;
l:=k+p+1;
last:=1;
cost:=1;
lk:=0;
while x<>0 do
begin
k:=x mod 10;
for i:=1 to k do
begin
inc(n);
build(last,n,1,-cost);
build(n,last+k+1,1,0);
end;
cost:=cost*10;
inc(n);
if last<>1 then
begin
if lk<k then
build(1,last,k-lk,0);
if k<lk then
build(last,n,lk-k,0);
end;
last:=n;
x:=x div 10;
if lk<k then lk:=k;
end;
build(1,n,1,d);
solve:=-work;
end;
begin
readln(a,b);
left:=1;
right:=1000000000;
while right-left>15000 do
begin
ans:=(left+right)shr 1;
if solve(ans,b)>a then
right:=ans
else left:=ans;
end;
for i:=left to right do
if solve(i,b)=a then
begin
writeln(i);
halt;
end;
end.
面向对象的解法:
program p1000;
var a,b,c:qword;
function max(a,b:qword):qword;
begin
if a<b then exit(b)
else exit(a);
end;
operator :=(a:qword):b:qword;
begin
b:=0;
if max(a,b)=a then b:=max(a,b)
else b:=min(a,b);
end;
operator +(a,b:qword)c:qword;
begin
c:=0;
c:=max(a,b)+min(a,b);
end;
begin
readln(a,b);
c:=a+b;
writeln(c);
end
2015年09月28日 14点09分 6
还有这个东西不是我写的。。本人蒟蒻网络流sap不会写只会dinic
2015年09月28日 14点09分
level 15
666[滑稽]
2015年09月29日 05点09分 7
level 8
徐一凡_exe 楼主
我用试图Pascal解决说谎者悖论:
function z:boolean;
begin
z:=not z();//模拟说谎者悖论
end;
begin
write(z);
end.
本来想解决此悖论从而举世闻名,想不到不仅运行了一分钟还没出结果,电脑内存还爆了。没办法,重装系统吧······
2015年09月29日 13点09分 8
不要看第3行。
2015年09月29日 13点09分
level 8
徐一凡_exe 楼主
请大声回答:好玩吗?
2015年09月30日 08点09分 9
大声地[滑稽]你个水笔
2015年10月02日 11点10分
level 8
good job
2015年09月30日 09点09分 10
level 11
...
2015年10月01日 02点10分 11
level 12
没了?
2015年10月02日 10点10分 12
1