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

主頁 > 知識庫 > shell腳本打印國際象棋棋盤

shell腳本打印國際象棋棋盤

熱門標簽:輝縣市地圖標注 湖北孝感如何辦理 北京電銷機器人對市場的影響 武漢語音電銷機器人加盟 地圖標注x是啥意思 同花順電話機器人微信 外呼系統的合法性 房產證地圖標注的兩個面積 威海電銷外呼系統好用嗎

本文實例為大家分享了shell打印國際象棋棋盤的具體代碼,供大家參考,具體內容如下

代碼如下:

#!/bin/bash

#set chess cell's width
read -p "Please set the chess cell's width( two space width as unit ):" width
if [[ $width =~ "^[0-9]+$" ]];then
 echo "wrong width setting, check your input and try again."
 exit
fi
let width=$width*2

#choose player's board cell color
player="player1"
PS3="Which color do you want to set for $player :"
select choice in red green yellow blue purple cyan white;do
 case $REPLY in
 [1-7])
 if [[ $player == player2 ]];then
  declare -i color2=$REPLY
  break
 else
  declare -i color1=$REPLY
 fi
 player="player2"
 PS3="Which color do you want to set for $player :"
 ;;
 *)
 ;;
 esac
done
if (( color1==color2 ));then
 echo "two player must choose different color, check your choice and try again."
 exit
fi

#print the chess board
for (( i=0; i4; i++ )); do
 for (( j=0; j$width/2; j++ ));do
 for (( k=0; k4; k++ ));do
  echo -e "\e[4${color1}m$(printf %${width}s)\e[0m\c"
  echo -e "\e[4${color2}m$(printf %${width}s)\e[0m\c"
 done
 echo
 done
 for (( j=0; j$width/2; j++ ));do
 for (( k=0; k4; k++ ));do
  echo -e "\e[4${color2}m$(printf %${width}s)\e[0m\c"
  echo -e "\e[4${color1}m$(printf %${width}s)\e[0m\c"
 done
 echo
 done
done

參考文章:

Linux Shell編程繪制國際象棋棋盤

Shell 教程

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

您可能感興趣的文章:
  • linux shell之控制臺打印各種顏色字體和背景的實現方法
  • shell中使用echo打印彩色字體和彩色背景的方法
  • shell實現數字打印從100到200的數
  • shell打印給定日期的日歷

標簽:麗江 蚌埠 武威 紹興 迪慶 日喀則 西寧 安康

巨人網絡通訊聲明:本文標題《shell腳本打印國際象棋棋盤》,本文關鍵詞  shell,腳本,打印,國際象棋,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《shell腳本打印國際象棋棋盤》相關的同類信息!
  • 本頁收集關于shell腳本打印國際象棋棋盤的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 和静县| 牟定县| 龙南县| 牟定县| 洞头县| 白银市| 临漳县| 南郑县| 永善县| 高邑县| 内乡县| 延安市| 云浮市| 巫溪县| 瑞安市| 和政县| 和静县| 绥阳县| 万源市| 临西县| 丰城市| 房山区| 托里县| 翁牛特旗| 黄浦区| 汝州市| 黔江区| 安远县| 嘉鱼县| 陵水| 溧水县| 牡丹江市| 康保县| 凭祥市| 南城县| 斗六市| 南投县| 越西县| 郸城县| 商丘市| 兴国县|