91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

怎么用批處理實現文本內容居中顯示

發布時間:2021-09-30 09:25:19 來源:億速云 閱讀:200 作者:小新 欄目:開發技術

這篇文章主要介紹了怎么用批處理實現文本內容居中顯示,具有一定借鑒價值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。

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.txt&echo 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.txt&pause>nul&goto :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%%%<NUL&ECHO.

感謝你能夠認真閱讀完這篇文章,希望小編分享的“怎么用批處理實現文本內容居中顯示”這篇文章對大家有幫助,同時也希望大家多多支持億速云,關注億速云行業資訊頻道,更多相關知識等著你來學習!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

大埔县| 长春市| 通州市| 石狮市| 河北区| 土默特右旗| 平遥县| 石柱| 东方市| 房山区| 安泽县| 清原| 从化市| 银川市| 遂昌县| 陆川县| 安平县| 东莞市| 隆化县| 怀宁县| 武陟县| 封开县| 泸定县| 贵定县| 柳州市| 赤水市| 驻马店市| 兴业县| 蓝山县| 海丰县| 南漳县| 南平市| 和林格尔县| 玉田县| 涞水县| 洛隆县| 桓台县| 克什克腾旗| 西宁市| 漳浦县| 象州县|