首页 > 学院 > 开发设计 > 正文

P1538 迎春舞会之数字舞蹈

2019-11-11 07:42:39
字体:
来源:转载
供稿:网友

题目描述

给出数字的大小k,用“ ”、“-”和“|”组成一系列数字。

样例输入

21234567890

样例输出

-- -- -- -- -- -- -- -- | | | | | | | | | | | | | || | | | | | | | | | | | | | -- -- -- -- -- -- -- | | | | | | | | | | | | || | | | | | | | | | | | | -- -- -- -- -- -- --

思路

相信也看出来了,这就是一个水题啊~~~不过注意空格的个数,数字两两之间存在一个空格。var a:string; i,j,k,l,n:longint;begin readln(n); readln(a); for i:=1 to length(a) do begin write(' '); if (a[i]='1')or(a[i]='4') then for j:=1 to n do write(' ') else for j:=1 to n do write('-'); write(' '); end; writeln; for i:=1 to n do begin for j:=1 to length(a) do begin if (a[j]='1')or(a[j]='2')or(a[j]='3')or(a[j]='7') then begin for k:=1 to n+1 do write(' '); write('| '); end else if (a[j]='5')or(a[j]='6') then begin write('|'); for k:=1 to n+2 do write(' '); end else begin write('|'); for k:=1 to n do write(' '); write('| '); end; end; writeln; end; for i:=1 to length(a) do begin write(' '); if (a[i]='1')or(a[i]='7')or(a[i]='0') then for j:=1 to n do write(' ') else for j:=1 to n do write('-'); write(' '); end; writeln; for i:=1 to n do begin for j:=1 to length(a) do begin if (a[j]='1')or(a[j]='3')or(a[j]='4')or(a[j]='5')or(a[j]='7')or(a[j]='9') then begin for k:=1 to n+1 do write(' '); write('| '); end else if a[j]='2' then begin write('|'); for k:=1 to n+2 do write(' '); end else begin write('|'); for k:=1 to n do write(' '); write('| '); end; end; writeln; end; for i:=1 to length(a) do begin write(' '); if (a[i]='1')or(a[i]='4')or(a[i]='7') then for j:=1 to n do write(' ') else for j:=1 to n do write('-'); write(' '); end; writeln;end.
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表