P1538 迎春舞會之數字舞蹈
2019-11-11 06:35:02
供稿:網友
題目描述
給出數字的大小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.