{"id":177821,"date":"2020-05-03T10:07:08","date_gmt":"2020-05-03T02:07:08","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=177821"},"modified":"2020-04-22T16:08:28","modified_gmt":"2020-04-22T08:08:28","slug":"linux-shuzi-game","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/linux-shuzi-game.html","title":{"rendered":"linux\u5b9e\u73b0\u731c\u6570\u5b57\u5c0f\u6e38\u620f"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u8fd9\u7bc7\u6587\u7ae0\u4e3b\u8981\u4e3a\u5927\u5bb6\u8be6\u7ec6\u4ecb\u7ecd\u4e86linux\u5b9e\u73b0\u731c\u6570\u5b57\u5c0f\u6e38\u620f\u6e90\u7801\uff0c\u6587\u4e2d\u793a\u4f8b\u4ee3\u7801\u4ecb\u7ecd\u7684\u975e\u5e38\u8be6\u7ec6\uff0c\u5177\u6709\u4e00\u5b9a\u7684\u53c2\u8003\u4ef7\u503c\uff0c\u611f\u5174\u8da3\u7684\u5c0f\u4f19\u4f34\u4eec\u53ef\u4ee5\u53c2\u8003\u4e00\u4e0b<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\"\"<\/p>\n

\u4e00\u4e2a\u7b80\u5355\u7684linux\u731c\u6570\u5b57\u5c0f\u6e38\u620f\u6e90\u7801<\/strong><\/div>\n
\u6e38\u620f\u89c4\u5219\uff1a<\/strong><\/span><\/div>\n

\u731c\u6570\u5b57\u6e38\u620f\u901a\u5e38\u7531\u4e24\u4e2a\u4eba\u73a9\uff0c\u4e00\u65b9\u51fa\u6570\u5b57\uff0c\u4e00\u65b9\u731c\u3002\u51fa\u6570\u5b57\u7684\u4eba\u8981\u60f3\u597d\u4e00\u4e2a\u6ca1\u6709\u91cd\u590d\u6570\u5b57\u7684 4 \u4e2a\u6570\uff0c\u4e0d\u80fd\u8ba9\u731c\u7684\u4eba\u77e5\u9053\u3002\u731c\u7684\u4eba\u5c31\u53ef\u4ee5\u5f00\u59cb\u731c\u3002\u6bcf\u731c\u4e00\u4e2a\u6570\u5b57\uff0c\u51fa\u6570\u8005\u5c31\u8981\u6839\u636e\u8fd9\u4e2a\u6570\u5b57\u7ed9\u51fa\u51e0 A \u51e0 B\uff0c\u5176\u4e2d A \u524d\u9762\u7684\u6570\u5b57\u8868\u793a\u4f4d\u7f6e\u6b63\u786e\u7684\u6570\u7684\u4e2a\u6570\uff0c\u800c B \u524d\u7684\u6570\u5b57\u8868\u793a\u6570\u5b57\u6b63\u786e\u800c\u4f4d\u7f6e\u4e0d\u5bf9\u7684\u6570\u7684\u4e2a\u6570\u3002\u5982\u6b63\u786e\u7b54\u6848\u4e3a 5234\uff0c\u800c\u731c\u7684\u4eba\u731c 5346\uff0c\u5219\u662f 1A2B\uff0c\u5176\u4e2d\u6709\u4e00\u4e2a 5 \u7684\u4f4d\u7f6e\u5bf9\u4e86\uff0c\u8bb0\u4e3a 1A\uff0c\u800c 3 \u548c 4 \u8fd9\u4e24\u4e2a\u6570\u5b57\u5bf9\u4e86\uff0c\u800c\u4f4d\u7f6e\u6ca1\u5bf9\uff0c\u56e0\u6b64\u8bb0\u4e3a 2B\uff0c\u5408\u8d77\u6765\u5c31\u662f 1A2B\u3002\u63a5\u7740\u731c\u7684\u4eba\u518d\u6839\u636e\u51fa\u9898\u8005\u7684\u51e0 A \u51e0 B \u7ee7\u7eed\u731c\uff0c\u76f4\u5230\u731c\u4e2d\uff08\u5373 4A0B\uff09\u4e3a\u6b62\u3002
\n\u731c\u7684\u4eba\u6709 8 \u6b21\u673a\u4f1a\u3002<\/p>\n

\u4f8b\u5982\uff1a<\/strong><\/span><\/div>\n

\u4e59\u51fa\u4e00\u4e2a\u6570\u5b57\uff0c\u7532\u731c\u3002
\n \u7532 \u4e59
\n1234 1A0B
\n 5678 2A1B
\n 5674 1A1B
\n 5638 1A1B
\n 2678 2A2B
\n 6278 4A0B(\u731c\u4e2d)<\/p>\n

\u6e90\u7801\uff1a<\/strong><\/span><\/div>\n
\r\n#!\/bin\/bash\r\nclear\r\necho\r\necho \"###################################################################\"\r\necho \"# this is a bash-shell game write by lee       #\"\r\necho \"# this game is infinite frequency \u731c\u6570\u5b57       #\"\r\necho \"#    version 2.1.1.20200421        #\"\r\necho \"###################################################################\"\r\necho -e \"\\n\\n\"\r\ndeclare INPUT\r\ndeclare PASSWORD\r\ndeclare LEN_PWD\r\ndeclare A\r\ndeclare B\r\ndeclare LOOP\r\n \r\n#this function is create random number\r\nrandom_number()\r\n{\r\n PASSWORD=$RANDOM\r\n LEN_PWD=`echo $PASSWORD | wc -L`\r\n if [[ $LEN_PWD -ne 4 ]]\r\n then\r\n random_number\r\n else\r\n #\u8f93\u51fa\u6807\u51c6\u503c\uff0c\u6d4b\u8bd5\u9700\u8981\uff0c\u5f00\u53d1\u5b8c\u6210\u6ce8\u91ca\u6389\r\n echo $PASSWORD\r\n input\r\n fi\r\n}\r\n \r\n#this function is accept the input from user's keyboard\r\ninput()\r\n{\r\n read -n4 -p \"please input a number between 0000-9999:\" input\r\n# 10#${input} \u8fdb\u5236\u8f6c\u6362\r\n if [[ 10#${input} -eq 10#${PASSWORD} ]]\r\n then\r\n echo -e \"\\n\"\r\n echo \"#############################################\"\r\n echo \"#congratulations!You have tried $LOOP times!#\"\r\n echo \"# The password is $PASSWORD !   #\"\r\n echo \"#############################################\"\r\n exit\r\n elif [[ $LOOP -eq 6 ]]\r\n then\r\n echo -e \"\\n\"\r\n echo \"You have tried $LOOP times!Game over!\"\r\n exit\r\n else\r\n A=0\r\n B=0\r\n count_a\r\n count_b\r\n echo -e \"\\n\"\r\n echo \"****************************\"\r\n  echo \"*  \"$A\"A\"$B\"B   *\"\r\n  echo \"****************************\"\r\n echo \"You have tried $LOOP times! You left `expr 6 - $LOOP` times!\"\r\n LOOP=`expr $LOOP + 1`\r\n input\r\n fi\r\n}\r\n \r\n#this function is count the variable A's value\r\ncount_a()\r\n{\r\n for i in `seq 4`\r\n do\r\n VAR_INPUT=`expr substr $input $i 1`\r\n for j in `seq 4`\r\n do\r\n VAR_PASSWORD=`expr substr $PASSWORD $j 1`\r\n if [[ $VAR_INPUT -eq $VAR_PASSWORD ]] && [[ $i -eq $j ]]\r\n then A=`expr $A + 1`\r\n fi\r\n done\r\n done\r\n}\r\n \r\n#this function is count the variable B's value\r\ncount_b()\r\n{\r\n for i in `seq 4`\r\n do\r\n VAR_INPUT=`expr substr $input $i 1`\r\n for j in `seq 4`\r\n do\r\n VAR_PASSWORD=`expr substr $PASSWORD $j 1`\r\n if [[ $VAR_INPUT -eq $VAR_PASSWORD ]] && [[ $i -ne $j ]]\r\n then B=`expr $B + 1`\r\n fi\r\n done\r\n done\r\n}\r\n \r\nLOOP=1\r\nrandom_number\r\n<\/pre>\n

\u4ee5\u4e0a\u5c31\u662f\u672c\u6587\u7684\u5168\u90e8\u5185\u5bb9\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u7684\u5b66\u4e60\u6709\u6240\u5e2e\u52a9<\/p>\n","protected":false},"excerpt":{"rendered":"

\u731c\u6570\u5b57\u6e38\u620f\u901a\u5e38\u7531\u4e24\u4e2a\u4eba\u73a9\uff0c\u4e00\u65b9\u51fa\u6570\u5b57\uff0c\u4e00\u65b9\u731c\u3002\u51fa\u6570\u5b57\u7684\u4eba\u8981\u60f3\u597d\u4e00\u4e2a\u6ca1\u6709\u91cd\u590d\u6570\u5b57\u7684 4 \u4e2a\u6570\uff0c\u4e0d\u80fd\u8ba9\u731c\u7684\u4eba\u77e5\u9053\u3002 […]<\/p>\n","protected":false},"author":1893,"featured_media":177786,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-177821","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/177821","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1893"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=177821"}],"version-history":[{"count":2,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/177821\/revisions"}],"predecessor-version":[{"id":177825,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/177821\/revisions\/177825"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/177786"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=177821"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=177821"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=177821"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}