{"id":881,"date":"2018-07-24T22:21:59","date_gmt":"2018-07-24T13:21:59","guid":{"rendered":"https:\/\/aoboshi.org\/?p=881"},"modified":"2018-07-24T23:03:47","modified_gmt":"2018-07-24T14:03:47","slug":"fuzzbuzz-sh%e5%be%ae%e8%aa%bf%e6%95%b4%e6%9c%80%e5%a4%a7%e5%80%a4%e3%82%92%e5%bc%95%e6%95%b0%e5%8c%96%e3%80%81%e5%bc%95%e6%95%b0%e3%83%81%e3%82%a7%e3%83%83%e3%82%af","status":"publish","type":"post","link":"https:\/\/aoboshi.org\/?p=881","title":{"rendered":"fuzzbuzz.sh\u5fae\u8abf\u6574(\u6700\u5927\u5024\u3092\u5f15\u6570\u5316\u3001\u5f15\u6570\u30c1\u30a7\u30c3\u30af)"},"content":{"rendered":"<p>\u4ee5\u524d\u4f5c\u6210\u3057\u305f\u3001<a href=\"https:\/\/aoboshi.org\/?p=419\">fizzbuzz.sh<\/a>\u3092\u5fae\u8abf\u6574\u3057\u307e\u3057\u305f\u3002<br \/>\n\u524d\u56de\u306ffizzbuzz\u3092\u7d42\u4e86\u3055\u305b\u308b\u6700\u5927\u5024\u3092\u30d9\u30bf\u66f8\u304d\u3057\u3066\u3044\u307e\u3057\u305f\u304c\u3001\u5f15\u6570\u5316\u3057\u307e\u3057\u305f\u3002<br \/>\n\u307e\u305f\u3001\u5f15\u6570\u304c\u5165\u3063\u3066\u3044\u306a\u304b\u3063\u305f\u308a\u3001\u6570\u5b57\u4ee5\u5916\u306e\u3082\u306e\u304c\u5165\u3063\u3066\u3044\u305f\u5834\u5408\u3092\u60f3\u5b9a\u3057\u3001\u5f15\u6570\u306e\u30c1\u30a7\u30c3\u30af\u3092\u884c\u3046\u51e6\u7406\u3092\u6700\u521d\u306b\u5165\u308c\u3066\u3044\u307e\u3059\u3002<br \/>\n(\u5f15\u6570\u304c\u8907\u6570\u5165\u3063\u3066\u308b\u72b6\u614b\u306b\u3064\u3044\u3066\u306f\u3001\u6700\u521d\u306e\u5f15\u6570\u3057\u304b\u53c2\u7167\u305b\u305a\u52d5\u4f5c\u306b\u554f\u984c\u306a\u3044\u305f\u3081\u3001\u4eca\u56de\u306f\u8003\u616e\u3057\u3066\u3044\u307e\u305b\u3093\u3002)<\/p>\n<p>#!\/bin\/sh<br \/>\n<strong>expr 1 + $1 >\/dev\/null 2>&#038;1<br \/>\nif [ $? -ne 0 ]; then<br \/>\n    echo &#8220;Please enter a correct parameter by number!&#8221;<br \/>\n    exit 3<br \/>\nelse<br \/>\n    max=$1<br \/>\nfi<\/strong><br \/>\nnum=1<br \/>\nwhile :<br \/>\ndo<br \/>\n     fizz=`expr ${num} % 3`<br \/>\n    buzz=`expr ${num} % 5`<br \/>\n    if [ ${fizz} = 0 -a ${buzz} = 0 ]; then<br \/>\n         echo &#8220;FizzBuzz&#8221;<br \/>\n    elif [ ${fizz} = 0 ]; then<br \/>\n         echo &#8220;Fizz&#8221;<br \/>\n    elif [ ${buzz} = 0 ]; then<br \/>\n         echo &#8220;Buzz&#8221;<br \/>\n    else<br \/>\n        echo ${num}<br \/>\n    fi<br \/>\n    num=`expr ${num} + 1`<br \/>\nif [ ${num} -gt <strong>${max}<\/strong> ]; then<br \/>\n     exit<br \/>\nfi<br \/>\ndone<br \/>\n\u5909\u66f4\u5834\u6240\u3092<strong>\u592a\u5b57<\/strong>\u3067\u8a18\u8f09\u3057\u3066\u3044\u307e\u3059\u3002(\u30a4\u30f3\u30c7\u30f3\u30c8\u304c\u8868\u793a\u3055\u308c\u306a\u3044\u306e\u306f\u3054\u611b\u5b0c&#8230;)<\/p>\n<p>\u3010\u5909\u66f4\u5834\u6240\u306e\u8aac\u660e\u3011<br \/>\n[\u5909\u66f4\u7b87\u62401]<br \/>\nexpr 1 + $1 >\/dev\/null 2>&#038;1<br \/>\nif [ $? -ne 0 ]; then<br \/>\n    echo &#8220;Please enter a parameter !&#8221;<br \/>\n    exit 3<br \/>\nelse<br \/>\n    max=$1<br \/>\nfi<\/p>\n<p>expr\u30671+\u5f15\u6570\u3092\u3059\u308b\u51e6\u7406\u3092\u884c\u3044\u307e\u3059\u3002<br \/>\nexpr\u306f\u6570\u5f0f\u3092\u8a08\u7b97\u3059\u308b\u30b3\u30de\u30f3\u30c9\u3067\u3059\u304c\u3001<br \/>\n\u6b63\u3057\u3044\u6570\u5f0f\u3092\u8a08\u7b97\u3057\u305f\u5834\u5408\u306f\u3001\u8fd4\u5024\u306f0\u3001\u6570\u5f0f\u304c\u629c\u3051\u3066\u3044\u305f\u308a\u3001\u6570\u5b57\u4ee5\u5916\u306e\u3082\u306e\u3092\u8a08\u7b97\u3057\u3088\u3046\u3068\u3057\u305f\u5834\u5408\u306f\u8fd4\u5024\u306f2\u3092\u8fd4\u3057\u307e\u3059\u3002<\/p>\n<p>pi@raspberrypi:~ $ expr 1 + 1<br \/>\n2<br \/>\npi@raspberrypi:~ $ echo $?<br \/>\n0<br \/>\npi@raspberrypi:~ $ expr 1 + a<br \/>\nexpr: non-integer argument<br \/>\npi@raspberrypi:~ $ echo $?<br \/>\n2<br \/>\npi@raspberrypi:~ $ expr 1 +<br \/>\nexpr: syntax error<br \/>\npi@raspberrypi:~ $ echo $?<br \/>\n2<br \/>\npi@raspberrypi:~ $<\/p>\n<p>\u3053\u308c\u3092\u5229\u7528\u3057\u3001expr\u30671+\u5f15\u6570\u3092\u8a08\u7b97\u3057\u3001(\u51fa\u529b\u306f\u8981\u3089\u306a\u3044\u306e\u3067\/dev\/null\u306b\u6368\u3066\u3066)<br \/>\n\u8fd4\u5024\u306f0\u306a\u3089\u3001\u6b63\u3057\u3044\u5f15\u6570\u30012\u306a\u3089\u7570\u5e38\u306a\u5f15\u6570\u304c\u6307\u5b9a\u3055\u308c\u3066\u3044\u308b\u3068\u5224\u65ad\u3057\u307e\u3059\u3002<br \/>\n\u5f15\u6570\u304c\u7570\u5e38\u306a\u5834\u5408\u306f\u300cPlease enter a parameter !\u300d\u3068\u51fa\u529b\u3057\u3066\u8fd4\u5024\u304c3\u3067\u7d42\u4e86\u3057\u307e\u3059\u3002<\/p>\n<p>\u305d\u3046\u3067\u306a\u3044\u5834\u5408\u306f\u6b63\u5e38\u306a\u5f15\u6570\u3067\u3042\u308b\u3068\u307f\u306a\u3057\u3001\u5f15\u6570\u3092\u5909\u6570\u300cmax\u300d\u306b\u4ee3\u5165\u3057\u307e\u3059\u3002<\/p>\n<p>[\u5909\u66f4\u7b87\u62402]<br \/>\nif [ ${num} -gt ${max} ]; then<br \/>\n\u30d9\u30bf\u66f8\u304d\u3057\u3066\u3044\u305f\u6700\u5927\u5024\u3092\u5909\u6570\u300cmax\u300d\u306b\u7f6e\u304d\u63db\u3048\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u4ee5\u4e0a\u306e\u4fee\u6b63\u3067\u3001\u5b89\u5168\u306b\u6700\u5927\u5024\u3092\u5f15\u6570\u5316\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3057\u305f\u3002<br \/>\n\u3082\u3046\u5c11\u3057\u6539\u5584\u3059\u3079\u304d\u3053\u3068\u304c\u3042\u308a\u307e\u3057\u305f\u3089\u3001\u307e\u305f\u6539\u826f\u3057\u3066\u307f\u3088\u3046\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4ee5\u524d\u4f5c\u6210\u3057\u305f\u3001fizzbuzz.sh\u3092\u5fae\u8abf\u6574\u3057\u307e\u3057\u305f\u3002 \u524d\u56de\u306ffizzbuzz\u3092\u7d42\u4e86\u3055\u305b\u308b\u6700\u5927\u5024\u3092\u30d9\u30bf\u66f8\u304d\u3057\u3066\u3044\u307e\u3057\u305f\u304c\u3001\u5f15\u6570\u5316\u3057\u307e\u3057\u305f\u3002 \u307e\u305f\u3001\u5f15\u6570\u304c\u5165\u3063\u3066\u3044\u306a\u304b\u3063\u305f\u308a\u3001\u6570\u5b57\u4ee5\u5916\u306e\u3082\u306e\u304c\u5165\u3063\u3066\u3044\u305f\u5834\u5408\u3092\u60f3\u5b9a\u3057\u3001\u5f15\u6570\u306e\u30c1 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-881","post","type-post","status-publish","format-standard","hentry","category-10"],"_links":{"self":[{"href":"https:\/\/aoboshi.org\/index.php?rest_route=\/wp\/v2\/posts\/881","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/aoboshi.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/aoboshi.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/aoboshi.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/aoboshi.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=881"}],"version-history":[{"count":0,"href":"https:\/\/aoboshi.org\/index.php?rest_route=\/wp\/v2\/posts\/881\/revisions"}],"wp:attachment":[{"href":"https:\/\/aoboshi.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=881"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/aoboshi.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=881"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/aoboshi.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=881"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}