本帖最后由 wankoilz 于 2015-10-10 22:19 编辑
- @echo off&setlocal enabledelayedexpansion
- set/p row=row:
- set/p col=col:
- set rowChar=$ABCDEF
- for /l %%a in (1,1,%row%) do (
- for /l %%b in (1,1,%col%) do (
- set row%%a=!row%%a!!rowChar:~%%a,1!%%b
- set col%%b=!col%%b!!rowChar:~%%a,1!%%b
- )
- )
- for /l %%a in (1,1,%row%) do echo !row%%a!
- for /l %%a in (1,1,%row%) do (
- set last=
- for %%b in (!row%%a!) do (
- if not "!last!"=="" set/p=!last!%%b <nul
- set last=%%b
- )
- echo;
- )
- for /l %%a in (2,1,%row%) do (
- for /l %%b in (1,1,%col%) do (
- set last=&set n=
- for %%c in (!col%%b!) do (
- set/a n+=1
- if !n! equ %%a set/p=!last!%%c <nul
- set last=%%c
- )
- )
- echo;
- )
- pause
复制代码 再来个awk的:- #&cls&@echo off&setlocal enabledelayedexpansion
- #&cls&set/p row=row:&set/p col=col:&set rowChar=$ABCDEF
- #&cls&(for /l %%a in (1,1,%row%) do (for /l %%b in (1,1,%col%) do set/p=!rowChar:~%%a,1!%%b <nul)&echo;)>a.txt
- #&cls&@gawk -f %0 a.txt>con&pause>nul&exit
-
- {for(i=1;i<=NF;i++){row[NR][i]=$i};print $0}
- END {
- for(i=1;i<=NR;i++){
- for(j=1;j<NF;j++){
- printf row[i][j]row[i][j+1]" "
- }
- print "\r"
- }
- for(i=1;i<NR;i++){
- for(j=1;j<=NF;j++){
- printf row[i][j]row[i+1][j]" "
- }
- print "\r"
- }
- }
复制代码
|