校园春色亚洲色图_亚洲视频分类_中文字幕精品一区二区精品_麻豆一区区三区四区产品精品蜜桃

主頁 > 知識庫 > 批處理實現文本內容居中顯示的代碼

批處理實現文本內容居中顯示的代碼

熱門標簽:浙江語音外呼系統招商 用電話機器人取代人工 aa專業電話外呼系統 沈陽電銷 無錫極信防封電銷卡價格 谷歌地圖標注錯位 外呼獲客系統 四川防封電銷卡套餐 95專業外呼線路是怎么回事
a.txt  
代碼:

[Promise don't come easy]
I should have known all along.
There was something wrong.
I just never read between the lines.
Then I woke up one day and found you on your way.
Leaving nothing but my heart behind.
What can I do to make it up to you.
Promises don't come easy.
But tell me if there's a way to bring you back home to stay.
Well I'd promises anything to you.
I've been walkin' around with my head hanging down.
Wondrin' what I'm gonna do.
'Cause when you walked out that door.
要求,CMD原始窗口中,不調節窗口大小,不生成臨時文件,居中顯示文本內容。輸出如下:
代碼:


[Promise don't come easy]
I should have known all along.
There was something wrong.
I just never read between the lines.
Then I woke up one day and found you on your way.
Leaving nothing but my heart behind.
What can I do to make it up to you.
Promises don't come easy.
But tell me if there's a way to bring you back home to stay.
Well I'd promises anything to you.
I've been walkin' around with my head hanging down.
Wondrin' what I'm gonna do.
'Cause when you walked out that door.

Batcher:

sed -e :a -e "s/^.\{1,77\}$/ /;ta" a.txt

sed.exe
http://xiazai.jb51.net/201010/tools/sed_jb51.rar 

batman:思路說明:
以下代碼是充分findstr命令的示例,使用findstr /n來取得行號同時兼容空行,
并將行號進行變量賦值;使用findstr /o來取得第行的字符偏移量,但要通過
上、下行的字符偏移差,因為字符偏移值是類計遞加的,同時每行回車增加
兩個字符偏移,所以不可避免要對最后一行強加回車,在不破壞原文件的情
況下只好生成臨時文件;利用findstr /o能夠一次性獲得文本所有行的字符偏
移量也就是字符總數,效率和逐字符判斷相比肯定是高得多了。
---------------------------------
復制代碼 代碼如下:

@echo off
copy /y 1.txt 2.txt>nul
echo.>>2.txtecho end>>2.txt
for /f "tokens=1,2* delims=: " %%i in ('findstr /n /o .* 2.txt') do (
set "_%%i=%%j"set ".%%i=%%k"
  if %%i geq 2 call :lp %%i
)
del /q 2.txtpause>nulgoto :eof
:lp
set /a n=%1-1
set /a num=_%1-_%n%-2
set /a kl=(80-num)/2
for /l %%i in (1,1,%kl%) do set /p= NUL
call,set /p=%%.%n%%%NULECHO.

標簽:南平 廣安 煙臺 青島 連云港 興安盟 常德 迪慶

巨人網絡通訊聲明:本文標題《批處理實現文本內容居中顯示的代碼》,本文關鍵詞  批處理,實現,文本,內容,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《批處理實現文本內容居中顯示的代碼》相關的同類信息!
  • 本頁收集關于批處理實現文本內容居中顯示的代碼的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 綦江县| 洛浦县| 内丘县| 泸西县| 子长县| 高尔夫| 台江县| 年辖:市辖区| 闸北区| 大洼县| 故城县| 沈丘县| 凌源市| 鄂温| 会同县| 屏山县| 峡江县| 五家渠市| 武宁县| 太原市| 同心县| 运城市| 金山区| 宁南县| 永平县| 岑巩县| 香格里拉县| 沁阳市| 台州市| 雷山县| 翁牛特旗| 鄂尔多斯市| 拜城县| 慈溪市| 潼关县| 马尔康县| 高雄市| 罗定市| 曲麻莱县| 庆云县| 苍梧县|