需要一宴数段时间编程啊
可以先用ch=getch()输入,然后用ch%2对每一位分离,顺序存进stack,然后倒序输出,就是ASC码和启了。
另外如果位运算学的好,可以用位运算做。
海明码晌棚首和循环冗余码记得学过,但都还给老师了……不好意思
20分钟内的作品……不过想剪枝想了好久结果发现不用拿旦……
vara:array[1..64] of integer
n,b,d:integer
i,j:integer
function haiming(a,b:integer):integer
var x:integer
begin
x:=a xor b
haiming:=(x and 1)+(x shr 1 and 1)+(x shr 2 and 1)+(x shr 3 and 1)+(x shr 4 and 1)+(x shr 5 and 1)+(x shr 6 and 1)+(x shr 7 and 1)
end
function t(i,j:integer):boolean
var k:integer
begin
for k:=1 to i-1 do if haiming(a[k],j)<d then exit(true)
exit(false)
end
procedure print
var i:integer
begin
for i:=1 辩敏州to n do
if i mod 10=0 then writeln(a[i])else write(a[i],' ')
携蔽 if n mod 10>0 then writeln
end
begin
read(n,b,d)a[1]:=0
for i:=2 to n do
begin
j:=a[i-1]+1while (j<1 shl b) and t(i,j) do inc(j)
if j=1 shl b then begin writeln('Exception:no valid answer')haltend
a[i]:=j
end
end.
要注释版本再说……价值15,注释5
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)