{"id":1395,"date":"2008-09-05T23:13:00","date_gmt":"2008-09-05T14:13:00","guid":{"rendered":"https:\/\/hdmr.org\/d\/?e=114"},"modified":"2008-09-05T23:13:00","modified_gmt":"2008-09-05T14:13:00","slug":"blogn-114","status":"publish","type":"post","link":"https:\/\/hdmr.org\/d\/?e=114","title":{"rendered":"\u30be\u30f3\u30d3\u304c\u6016\u3044\u304b\u3089\u3001\u30de\u30af\u30ed\u3067\u6226\u3046\u3053\u3068\u306b\u3057\u305f"},"content":{"rendered":"<p>C\u306e\u554f\u984c\u306f\u3001\u30e1\u30e2\u30ea\u7ba1\u7406\u3092\u81ea\u5206\u3067\u3084\u3089\u306a\u304f\u3066\u306f\u3044\u3051\u306a\u3044\u3053\u3068\u3002<br \/>C++\u306e\u6709\u540d\u306a\u30e9\u30a4\u30d6\u30e9\u30ea\u3001STL\u3067\u306f\u3001\u95a2\u6570\u3092\u51fa\u308b\u3068\u304d\u3001vector\u306a\u3069\u306e\u5b9f\u4f53\u306f\u7834\u68c4\u3055\u308c\u308b\u3002<br \/>\u3053\u308c\u306f\u3042\u308a\u304c\u305f\u3044\u3053\u3068\u3067\u3059\u306d\u3002<br \/>C\u306b\u3082\u305d\u3093\u306a\u4fbf\u5229\u306a\u6a5f\u80fd\u304c\u6b32\u3057\u3044\u306d\u3047\u3002C++\u306e\u3064\u307e\u307f\u98df\u3044\u3092\u3059\u308b\u306e\u30821\u3064\u3042\u308a\u3060\u3051\u3069\u2026<br \/>\u307e\u3041\u3057\u304b\u3057\u3001\u30e1\u30e2\u30ea\u7ba1\u7406\u3092\u3059\u308b\u3068\u3044\u3063\u3066\u3082\u3001\u78ba\u4fdd\u3057\u305f\u7a7a\u9593\u306f\u78ba\u304b\u306b\u7834\u68c4\u3057\u308d\u3068\u3002\u305d\u308c\u3060\u3051\u3067\u3059\u3002<br \/>\u3053\u308c\u3092\u5fd8\u308c\u308b\u3068\u3001\u30be\u30f3\u30d3\u3053\u3068\u6c38\u9060\u306b\u53c2\u7167\u3055\u308c\u306a\u3044\u7a7a\u9593\u304c\u767a\u751f\u3059\u308b\u3068\u3002<br \/>\u4f55\u5ea6\u3082\u547c\u3073\u51fa\u3055\u308c\u308b\u95a2\u6570\u3067\u3053\u308c\u304c\u3067\u304d\u308b\u3068\u3048\u3089\u3044\u3053\u3068\u3067\u3059\u3002<br \/>\u3053\u308c\u3092\u8003\u3048\u306a\u304f\u3066\u3082\u3044\u3044\u3088\u3046\u306b\u3001.NET Framework\u306b\u306fGC\u304c\u4ed8\u3044\u3066\u3044\u3066\u3001\u3053\u308c\u3067\u81ea\u52d5\u7684\u306b\u89e3\u653e\u3057\u3066\u304f\u308c\u308b\u3068\u3002<br \/>\u3042\u3042\u3042\u308a\u304c\u305f\u3044\u3002\u3068\u3044\u3046\u308f\u3051\u3067C#\u3092\u4f7f\u3048\u3070\u554f\u984c\u306f\u306a\u3044\u3067\u3059\u304c\u3001\u305d\u308c\u3067\u306f\u8a71\u304c\u305a\u308c\u3066\u3057\u307e\u3046\u306e\u3067\u3001C\u3092\u4f7f\u3046\u3053\u3068\u3060\u3051\u8003\u3048\u307e\u3057\u3087\u3046\u3002<\/p>\n<hr \/>\n<p>C\u306e\u4fbf\u5229\u306a\u6a5f\u80fd\u306b#define\u304c\u3042\u308a\u307e\u3059\u3002<br \/>\u3068\u3044\u3046\u3051\u3069\u3001\u6b63\u76f4\u8a00\u3046\u3068\u3001\u4e0d\u6c17\u5473\u306a\u8003\u3048\u65b9\u3067\u3059\u3051\u3069\u306d\u3002<br \/>\u666e\u901a\u306e\u4f7f\u3044\u65b9\u3002<\/p>\n<pre>#define SIZE 100<\/pre>\n<p>\u3053\u3046\u66f8\u304f\u3068\u3001\u30d7\u30ed\u30b0\u30e9\u30e0\u4e2d\u306e\u6587\u5b57\u5217\u3068\u3057\u3066\u306eSIZE\u4ee5\u5916\u306eSIZE\u304c\u5168\u90e8100\u306b\u7f6e\u63db\u3055\u308c\u307e\u3059\u3002<br \/>\u307e\u3041\u30ea\u30c6\u30e9\u30eb\u3092\u4f55\u56de\u3082\u66f8\u304b\u306a\u304f\u3066\u3082\u3001\u30b3\u30f3\u30d1\u30a4\u30e9\u304c\u66f8\u3044\u3066\u304f\u308c\u308b\u3068\u8a00\u3046\u3053\u3068\u3067\u3059\u3002<br \/>\u3053\u306e\u8003\u3048\u65b9\u3092\u62e1\u5f35\u3057\u305f\u30de\u30af\u30ed\u3068\u3044\u3046\u306e\u304c\u3042\u308b\u3002<\/p>\n<pre>#define SQU(x) ((x)*(x))<\/pre>\n<p>SQU( foo() )\u3068\u66f8\u304f\u3068\u3001((foo()*(foo()))\u306b\u7f6e\u63db\u3055\u308c\u308b\u3002<br \/>\u3053\u306e\u7121\u99c4\u306b\u591a\u3044\u62ec\u5f27\u306f\u6f14\u7b97\u5b50\u306e\u7d50\u5408\u9806\u5e8f\u306e\u3053\u3068\u3068\u304b\u8003\u3048\u308b\u3068\u3001\u5f15\u6570\u306f(x)\u306e\u3088\u3046\u306b\u66f8\u3044\u3066\u3001\u7b54\u3048\u3082\u5168\u90e8()\u3067\u56f2\u3046\u3068\u3002<br \/>\u3053\u306e\u7a0b\u5ea6\u306e\u3053\u3068\u304c\u5fc5\u8981\u3067\u3042\u308b\u3068\u3002<br \/>\u3057\u304b\u3082\u3053\u306e\u6b20\u70b9\u306f\u3001foo()\u304c2\u56de\u5b9f\u884c\u3055\u308c\u308b\u3053\u3068\u3002\u3082\u3057\u7d50\u679c\u304c\u5909\u308f\u3063\u305f\u3089\u3069\u3046\u3059\u308b\u3002<br \/>\u3060\u304b\u3089\u3053\u3046\u3044\u3046\u306e\u306f\u672c\u5f53\u306f\u4f5c\u3063\u3066\u306f\u3044\u3051\u307e\u305b\u3093\u3002<br \/>\u305f\u3060\u95a2\u6570\u3092\u547c\u3073\u51fa\u3059\u3088\u308a\u8efd\u3044\u3068\u3044\u3046\u8a71\u3082\u3042\u308b\u3068\u3002\u3051\u3069\u3082\u306f\u3084\u6642\u4ee3\u9045\u308c\u306e\u610f\u898b\u306e\u3088\u3046\u306a\u2026<br \/>\u307e\u3041\u3042\u304f\u307e\u3067\u3082\u30b3\u30f3\u30d1\u30a4\u30e9\u304c\u7f6e\u63db\u3057\u3066\u304f\u308c\u308b\u3060\u3051\u3001\u305d\u3046\u8003\u3048\u307e\u3057\u3087\u3046\u3002<br \/>\u4eca\u56de\u306f\u3053\u306e\u30de\u30af\u30ed\u3092\u5229\u7528\u3057\u305f\u304a\u8a71\u3002<\/p>\n<hr \/>\n<p>\u3055\u3066\u3001\u4eca\u56de\u53c2\u8003\u306b\u3057\u305f\u306e\u306fC#\u306e\u3053\u3093\u306a\u69cb\u6587\u3002<\/p>\n<pre>using(System.IO.StreamReader mysr=new System.IO.StreamReader(\"test.txt\")){<br \/>  \/\/mysr\u304c\u4f7f\u3048\u308b<br \/>}<br \/>\/\/mysr\u306f\u4f7f\u3048\u306a\u3044\u3002<\/pre>\n<p>\u3053\u308c\u306fGC\u5bfe\u8c61\u5916\u306e\u30d5\u30a1\u30a4\u30eb\u95a2\u4fc2\u306e\u30af\u30e9\u30b9\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u78ba\u5b9f\u306b\u7834\u68c4\u3059\u308b\u306e\u306b\u4f7f\u308f\u308c\u308b\u3002<br \/>\u3053\u308c\u306b\u3088\u3063\u3066\u975e\u5e38\u306b\u4f7f\u3044\u3084\u3059\u3044\u3002\u306a\u306e\u3067using\u3092\u4f7f\u3046\u3053\u3068\u3092\u50d5\u306f\u63a8\u5968\u3057\u3066\u3044\u307e\u3059\u3002<br \/>\u3053\u306eusing\u3092\u307e\u306d\u3066\u307f\u3088\u3046\u3068\u304a\u3082\u3063\u305f\u3002<\/p>\n<pre>#define USINGARRAY(array,size,BLOCK) \\<br \/>  do{\\<br \/>    void* __ref = calloc(sizeof(*(array)),size);\\<br \/>    if( __ref == NULL) abort();\\<br \/>    (array)=__ref; \\<br \/>    do{\\<br \/>      BLOCK\\<br \/>    }while(0);\\<br \/>    free(__ref);\\<br \/>  }while(0)<\/pre>\n<p>#define\u306f\u672c\u6765\u4e00\u884c\u3067\u7d42\u308f\u308a\u307e\u3059\u304c\u3001\\\u3092\u4ed8\u3051\u308c\u3070\u6b21\u306e\u884c\u306b\u7d9a\u3051\u3089\u308c\u307e\u3059\u3002<br \/>\u5168\u4f53\u3092do{\uff5e}while(0)\u3067\u56f2\u3093\u3067\u3044\u307e\u3059\u304c\u3001\u3053\u308c\u306f\u305d\u3046\u3044\u3046\u3082\u306e\u3067\u3059\u3002\u3055\u3063\u304d\u306e()\u3068\u540c\u3058\u3088\u3046\u306a\u611f\u3058\u3067\u3059\u3002<br \/>\u6700\u5f8c\u306b;\u306f\u3042\u308a\u307e\u305b\u3093\u304c\u3001\u30de\u30af\u30ed\u3092\u4f7f\u3046\u65b9\u304c\u66f8\u3044\u3066\u304f\u308c\u308b\u3068\u601d\u3046\u306e\u3067\u3044\u308a\u307e\u305b\u3093\u3002<br \/>BLOCK\u306e\u4e2d\u306b\u5b9f\u969b\u306b\u5b9f\u884c\u3059\u308b\u6587\u304c\u5165\u308b\u306e\u3067\u3059\u304c\u3001\u306a\u3093\u304b\u77e5\u3089\u3093\u3051\u3069\u3046\u307e\u3044\u3053\u3068\u884c\u304d\u307e\u3059\u3002<br \/>\u3051\u3069\u3001int a,b;\u306e\u3088\u3046\u306a\u306e\u3092\u30d6\u30ed\u30c3\u30af\u5185\u306b\u66f8\u304f\u3068\u3060\u3081\u3067\u3059\u3051\u3069\u306d\u3002\u30ab\u30f3\u30de\u306f\u5acc\u3044\u3089\u3057\u3044\u3002<br \/>\u540c\u69d8\u306b\u30d5\u30a1\u30a4\u30eb\u306e\u3084\u3064\u3082\u4f5c\u3063\u3066\u307f\u305f\u3002<\/p>\n<pre>#define USINGFILE(fp,fname,fmode,BLOCK) \\<br \/>  do{\\<br \/>    FILE* __fp=fopen((fname),(fmode));\\<br \/>    if(__fp==NULL)  abort();\\<br \/>    (fp)=__fp;\\<br \/>      do{\\<br \/>        BLOCK\\<br \/>      }while(0);\\<br \/>    fclose(fp);\\<br \/>  }while(0)<\/pre>\n<p>\u307e\u3041\u3053\u3093\u306a\u98a8\u306b\u3001\u59cb\u307e\u308a\u3068\u7d42\u308f\u308a\u3092\u3057\u3063\u304b\u308a\u5bfe\u5fdc\u3055\u305b\u308b\u3002<br \/>\u305d\u3046\u3044\u3046\u3053\u3068\u3092\u5f37\u5236\u3055\u305b\u308b\u308f\u3051\u3067\u3059\u3002<br \/>\u305f\u3060\u3057\u3001\u975e\u5e38\u306b\u6271\u3044\u304c\u60aa\u3044\u3002\u307e\u3068\u3082\u306b\u30c7\u30d0\u30c3\u30b0\u3067\u304d\u306a\u3044\u3088\u3002<\/p>\n<hr \/>\n<p>\u3055\u3066\u3001\u3053\u308c\u3092\u4f7f\u3063\u305f\u30d7\u30ed\u30b0\u30e9\u30e0\u3002<\/p>\n<pre>main(){<br \/>  int* myarr;<br \/>  int size;<br \/>  FILE* fp;<br \/>  int i;<br \/>  double average=0.0,variance=0.0;<br \/>  USINGFILE(fp,\"test.txt\",\"r\",<br \/>    if( fscanf(fp,\"%d\",&size)!=1 ) abort();<br \/>    USINGARRAY(myarr,size,<br \/>      for(i=0;i<size;i++){<br \/>        if(fscanf(fp,\"%d\",&myarr[i])!=1)  abort();<br \/>      }<br \/>      for(i=0;i<size;i++)  average+=myarr[i];<br \/>      average\/=size;<br \/>      for(i=0;i<size;i++)  variance+=SQU(myarr[i]-average);<br \/>      variance\/=(size-1);<br \/>    );<br \/>  );<br \/>  printf(\"%f \/ %f\",average,sqrt(variance));<br \/>  return 0;<br \/>}<\/pre>\n<p>1\u884c\u305a\u3064\u8aad\u307f\u8fbc\u307f\u305f\u3044\u306e\u3067\u3059\u304c\u3001\u4e0b\u54c1\u306a\u306e\u3067\u3053\u3046\u3044\u3046fscanf\u306e\u4f7f\u3044\u65b9\u306f\u3084\u3081\u307e\u3057\u3087\u3046\u3002<br \/>\u3068\u306f\u3044\u3046\u3051\u3069\u3001\u3061\u3083\u3093\u3068\u8aad\u307f\u8fbc\u3081\u3066\u308b\u304b\u3001\u8aad\u307f\u8fbc\u3093\u3060\u500b\u6570\u3092\u30c1\u30a7\u30c3\u30af\u3057\u3066\u308b\u304b\u3089\u3001<br \/>fscanf\u306e\u30d0\u30c3\u30d5\u30a1\u306b\u30be\u30f3\u30d3\u304c\u6b8b\u3063\u305f\u308a\u3057\u306a\u3044\u306e\u3067\u307e\u3060\u5b89\u5fc3\u3067\u3059\u3002\u512a\u30fb\u826f\u30fb\u53ef\u30fb\u4e0d\u53ef\u3067\u8a00\u3048\u3070\u826f\u3050\u3089\u3044\u306e\u3082\u3093\u3067\u3059\u3002<br \/>fgets\u3067\u8aad\u307f\u8fbc\u3093\u3067\u3001sscanf\u3059\u308b\u65b9\u304c\u3044\u3044\u3067\u3059\u3002\u3053\u308c\u3060\u30681\u884c\u306b\u4f55\u500b\u5024\u304c\u66f8\u3044\u3066\u3042\u3063\u3066\u3082\u3044\u3044\u3053\u3068\u306b\u306a\u308b\u306e\u3067\u3002<br \/>\u3055\u3066\u3001\u6700\u5f8c\u306e\u5f15\u6570\u304c\u3059\u3054\u304f\u9577\u3044\u306e\u3067\u6c17\u6301\u3061\u60aa\u3044\u3067\u3059\u304c\u3001\u304d\u3061\u3093\u3068\u59cb\u307e\u308a\u3001\u7d42\u308f\u308a\u306e\u95a2\u4fc2\u304c\u898b\u3048\u307e\u3059\u306d\u3002<br \/>\u3053\u308c\u3082\u4e07\u80fd\u3067\u306f\u306a\u3044\u3067\u3059\u3088\u3002\u914d\u5217\u306e\u914d\u5217\u306a\u3093\u304b\u306f\u3053\u308c\u3067\u306f\u51e6\u7406\u3067\u304d\u306a\u3044\u3002<br \/>\u307e\u3041\u4f55\u304c\u8a00\u3044\u305f\u304b\u3063\u305f\u304b\u3068\u3044\u3046\u3068\u3001\u78ba\u4fdd\u3068\u7834\u68c4\u306f\u4e00\u5bfe\u4e00\u5bfe\u5fdc\u3057\u306a\u3051\u308c\u3070\u3044\u3051\u306a\u3044\u3002<br \/>\u305d\u308c\u304c\u3067\u304d\u306a\u3044\u306a\u3089\u3070\u3001\u305d\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u306f\u3061\u3087\u3063\u3068\u5371\u967a\u3060\u3068\u3002\u305d\u3046\u601d\u3044\u307e\u3059\u3088\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>C\u306e\u554f\u984c\u306f\u3001\u30e1\u30e2\u30ea\u7ba1\u7406\u3092\u81ea\u5206\u3067\u3084\u3089\u306a\u304f\u3066\u306f\u3044\u3051\u306a\u3044\u3053\u3068\u3002C++\u306e\u6709\u540d\u306a\u30e9\u30a4\u30d6\u30e9\u30ea\u3001STL\u3067\u306f\u3001\u95a2\u6570\u3092\u51fa\u308b\u3068\u304d\u3001vector\u306a\u3069\u306e\u5b9f\u4f53\u306f\u7834\u68c4\u3055\u308c\u308b\u3002\u3053\u308c\u306f\u3042\u308a\u304c\u305f\u3044\u3053\u3068\u3067\u3059\u306d\u3002C\u306b\u3082\u305d\u3093\u306a\u4fbf\u5229\u306a\u6a5f\u80fd\u304c\u6b32\u3057\u3044\u306d\u3047\u3002C++\u306e\u3064 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-1395","post","type-post","status-publish","format-standard","hentry","category-computer"],"_links":{"self":[{"href":"https:\/\/hdmr.org\/d\/index.php?rest_route=\/wp\/v2\/posts\/1395","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hdmr.org\/d\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hdmr.org\/d\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hdmr.org\/d\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hdmr.org\/d\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1395"}],"version-history":[{"count":0,"href":"https:\/\/hdmr.org\/d\/index.php?rest_route=\/wp\/v2\/posts\/1395\/revisions"}],"wp:attachment":[{"href":"https:\/\/hdmr.org\/d\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1395"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hdmr.org\/d\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1395"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hdmr.org\/d\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1395"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}