{"id":323,"date":"2023-09-16T10:32:10","date_gmt":"2023-09-16T02:32:10","guid":{"rendered":""},"modified":"2023-09-18T11:49:45","modified_gmt":"2023-09-18T03:49:45","slug":"%e5%a6%82%e4%bd%95%e5%88%9d%e5%a7%8b%e5%8c%96%e6%95%b0%e7%bb%84","status":"publish","type":"post","link":"https:\/\/mushiming.com\/323.html","title":{"rendered":"\u5982\u4f55\u521d\u59cb\u5316\u6570\u7ec4"},"content":{"rendered":"

\n <\/path> \n<\/svg> <\/p>\n

\u5206\u6790<\/strong>\uff1a\u5982\u679c\u76f4\u63a5\u8f93\u51fa\u672a\u521d\u59cb\u5316\u7684\u6570\u7ec4\u5143\u7d20\u503c\uff0c\u4ee5\u89c2\u5bdf\u672a\u521d\u59cb\u5316\u7684\u6570\u7ec4\uff0c\u5b9e\u73b0\u65b9\u6cd5\u4ee3\u7801\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n

#include<stdio.h><\/span>\n#define SIZE 10<\/span>\nint<\/span> main()\n{\n    int<\/span> array<\/span>[SIZE] ;\n    int<\/span> i = 0<\/span>;\n    for<\/span>(i = 0<\/span>;i < SIZE; i++)\n    {\n       printf<\/span>(\"arry[%d] = %d\\n\"<\/span>,i,array<\/span>[i]);\n    }\n    return<\/span> 0<\/span>;\n}<\/code><\/pre>\n

\u8fd0\u884c\u7ed3\u679c\u5982\u4e0b\uff1a
\"\u5982\u4f55\u521d\u59cb\u5316\u6570\u7ec4<\/p>\n

       \u5bf9\u4e8e\u8f93\u51fa\u7ed3\u679c\uff0c\u53ef\u80fd\u5927\u591a\u6570\u521d\u5b66\u7684\u4eba\u53ef\u80fd\u4e0d\u61c2\u3002\u6240\u4ee5\uff0c\u4e3a\u4e86\u6570\u636e\u5b89\u5168\uff0c\u5bf9\u6570\u7ec4\u4e5f\u5fc5\u987b\u521d\u59cb\u5316\u3002<\/p>\n

\u5206\u6790<\/strong> \uff1a \u7531\u4e8e\u6570\u7ec4\u672a\u521d\u59cb\u5316\uff0c\u5404\u5143\u7d20\u7684\u503c\u5341\u5206\u7d0a\u4e71\u3002\u5176\u5185\u5b58\u5185\u5bb9\u4e3a\u7f16\u8bd1\u5668\u5206\u914d\u5185\u5b58\u524d\u7684\u539f\u59cb\u72b6\u6001\uff0c\u56e0\u6b64\uff0c\u91cc\u9762\u5b58\u653e\u7684\u662f\u4f60\u4e0d\u53ef\u80fd\u77e5\u9053\u7684\u6570\u636e\u3002\u4ece\u7a0b\u5e8f\u8f93\u51fa\u7684\u7ed3\u679c\u4e2d\u4e5f\u53ef\u4ee5\u770b\u5230\uff0c\u672a\u7ecf\u521d\u59cb\u5316\u7684\u6570\u7ec4\u4e2d\u5143\u7d20\u7684\u6570\u503c\u90fd\u662f\u6df7\u4e71\u7684\u3002\u82e5\u5728\u8fd9\u65f6\u4f7f\u7528\u8fd9\u4e9b\u6570\u7ec4\u5143\u7d20\uff0c\u5c06\u4f1a\u5bfc\u81f4\u4e00\u4e9b\u4e0d\u53ef\u9884\u77e5\u7684\u95ee\u9898(\u4e25\u91cd\u7684\u751a\u81f3\u5bfc\u81f4\u7cfb\u7edf\u762b\u75ea)\u3002\u56e0\u6b64\uff0c\u4e3a\u4e86\u907f\u514d\u51fa\u73b0\u4e00\u4e9b\u4e0d\u5fc5\u8981\u7684\u9519\u8bef\uff0c\u6570\u7ec4\u4e00\u7ecf\u5b9a\u4e49\uff0c\u6700\u597d\u7acb\u5373\u5bf9\u6570\u7ec4\u8fdb\u884c\u521d\u59cb\u5316\u3002<\/p>\n

       \u6570\u7ec4\u7684\u521d\u59cb\u5316\uff0c\u5c31\u662f\u5b9a\u4e49\u6570\u7ec4\u53d8\u91cf\u7684\u540c\u65f6\u7ed9\u5176\u4e2d\u7684\u6570\u7ec4\u5143\u7d20\u8d4b\u503c\uff0c\u7531\u4e8e\u662f\u7ed9\u591a\u4e2a\u5143\u7d20\u540c\u65f6\u8d4b\u503c\uff0c\u56e0\u6b64\uff0c\u5f62\u5f0f\u4e0a\u4e0e\u5355\u4e2a\u53d8\u91cf\u8d4b\u503c\u6709\u6240\u4e0d\u540c\u3002\u4e3b\u8981\u6709\u4e00\u4e0b\u4e09\u79cd\u5f62\u52bf\u3002<\/p>\n

\u5f62\u52bf\u4e00<\/strong>
       \u5bf9\u6570\u7ec4\u4e2d\u7684\u6240\u6709\u5143\u7d20\u5206\u522b\u5355\u72ec\u8d4b\u503c\uff0c\u628a\u521d\u59cb\u5316\u503c\u6309\u5e8f\u5217\u4f9d\u6b21\u653e\u5728\u82b1\u62ec\u53f7\u4e2d\uff0c\u5e76\u4f7f\u7528\u9017\u53f7\u9694\u5f00\uff0c\u5b9e\u73b0\u5bf9\u6570\u7ec4\u5404\u4e2a\u5143\u7d20\u7684\u8d4b\u503c\uff0c\u5f62\u5f0f\u5982\u4e0b:<\/p>\n

\u6570\u636e\u7c7b\u578b \u6570\u7ec4\u540d[N<\/span>] ={\u503c0\uff0c\u503c1\uff0c\u503c2\uff0c\u2026\u2026\u503c(n-1)}<\/span>;\n<\/code><\/pre>\n

\u82b1\u62ec\u53f7\u5185\u7684\u6700\u540e\u4e00\u4e2a\u503c\u540e\uff0c\u4e5f\u53ef\u4ee5\u8ddf\u4e00\u4e2a\u9017\u53f7\uff0c\u5f62\u5f0f\u5982\u4e0b:<\/p>\n

\u6570\u636e\u7c7b\u578b \u6570\u7ec4\u540d[N<\/span>] ={\u503c0\uff0c\u503c1\uff0c\u503c2\uff0c\u2026\u2026\u503c(n-1)\uff0c}<\/span>;\n<\/code><\/pre>\n

\u5176\u4e2d\uff0c\u82b1\u62ec\u53f7\u5185\u7684\u503c0\u8d4b\u503c\u7ed9\u6570\u7ec4\u7684\u7b2c\u4e00\u4e2a\u5143\u7d20\uff0c\u503c1\u8d4b\u503c\u7ed9\u7b2c\u4e8c\u4e2a\u5143\u7d20\uff0c\u2026\u2026\u503c(N-1)\u8d4b\u503c\u7ed9\u7b2cN\u4e2a\u5143\u7d20\u3002\u4f8b\u5982:<\/p>\n

int hours[12]<\/span>={123456789101112}; <\/span><\/code><\/pre>\n

\u4e5f\u53ef\u4ee5\u5728\u6700\u540e\u4e00\u4e2a\u5143\u7d20\u540e\u9762\u8ddf\u4e00\u4e2a\u9017\u53f7\uff0c\u5f62\u5f0f\u5982\u4e0b:<\/p>\n

int<\/span> hours[12<\/span>]={\n  \n  1<\/span>\uff0c2<\/span>\uff0c3<\/span>\uff0c4<\/span>\uff0c5<\/span>\uff0c6<\/span>\uff0c7<\/span>\uff0c8<\/span>\uff0c9<\/span>\uff0c10<\/span>\uff0c11<\/span>\uff0c12<\/span>};\/*\u6700\u540e\u4e00\u4e2a\u503c\u540e\u4e5f\u53ef\u4ee5\u8ddf\u9017\u53f7\uff0c\u8fd9\u4e2a \u6709\u70b9\u4e0d\u7f8e\u89c2\uff0c\u4e0d\u63a8\u8350*\/<\/span><\/code><\/pre>\n

       \u6267\u884c\u521d\u59cb\u5316\u540e\uff0c\u82b1\u62ec\u53f7\u5185\u503c\u5e8f\u5217\u4f9d\u6b21\u8d4b\u503c\u7ed9hours\u7684\u5143\u7d20\uff0chours[0]\u4e3a1\uff0chours[1]\u4e3a2\uff0c
hours[2]\u4e3a3\uff0chours[3]\u4e3a4\uff0chours[4]\u4e3a5\uff0chours[5]\u4e3a6\uff0chours[6]\u4e3a7\uff0chours[7]\u4e3a8\uff0chours[8]\u4e3a9\uff0chours[9]\u4e3a10\uff0chours[10]\u4e3a11\uff0chours[1]\u4e3a12\u3002
\u540c\u65f6\uff0c\u521d\u59cb\u5316\u7684\u6570\u503c\u5e8f\u5217\u4e0d\u80fd\u5927\u4e8e\u6570\u7ec4\u5bb9\u91cf\u3002\u4f8b\u5982:<\/p>\n

int<\/span> year<\/span>[4<\/span>]={\n  \n  356<\/span>\uff0c355<\/span>\uff0c355<\/span>\uff0c355<\/span>\uff0c356<\/span>};\n<\/code><\/pre>\n

     \u7531\u4e8e\u5c06\u4e94\u4e2a\u6570\u503c\u8d4b\u503c\u53ea\u80fd\u4fdd\u5b58\u56db\u4e2a\u5143\u7d20\u7684\u6570\u7ec4\u53d8\u91cf\uff0c\u6240\u4ee5\u7f16\u8bd1\u5668\u4f1a\u62a5\u9519:\u201dtwo many initializers\u201d(\u592a\u591a\u521d\u59cb\u503c)\u3002
\u5f62\u5f0f\u4e8c<\/strong>
       \u4e5f\u53ef\u4ee5\u53ea\u7ed9\u6570\u7ec4\u7684\u90e8\u5206\u5143\u7d20\u8d4b\u503c\uff0c\u7f16\u8bd1\u5668\u4f1a\u81ea\u52a8\u628a\u5269\u4f59\u5143\u7d20\u7684\u5185\u5b58\u7a7a\u95f4\u521d\u59cb\u5316\u4e3a0\uff0c\u5982\u679c\u7c7b\u578b\u662fint\u578b\uff0c\u4e3a0\uff0c\u5982\u679c\u4e3a\u6d6e\u70b9\u578b\uff0c\u5219\u8d4b\u503c\u4e3a0.000000\u3002\u6807\u51c6\u5f62\u5f0f\u5982\u4e0b:<\/p>\n

\u6570\u636e\u7c7b\u578b \u6570\u7ec4\u540d[N<\/span>] ={\u503c0\uff0c\u503c1\uff0c\u503c2\uff0c\u2026\u2026\u503cn}<\/span>;\/*\u5176\u4e2dn<N<\/span>-1<\/span>*\/<\/code><\/pre>\n

\u5176\u4e2d\uff0c\u6570\u7ec4\u7684\u7b2c\u4e00\u4e2a\u5230\u7b2cN\u4e2a\u5143\u7d20\u4f1a\u88ab\u4f9d\u6b21\u521d\u59cb\u5316\u4e3a\u503c0\u5230\u503cn\uff0c\u5269\u4f59\u7684\u5143\u7d20\u4f1a\u88ab\u521d\u59cb\u5316\u4e3a0\u3002\u5b9e\u4f8b\u5982\u4e0b:<\/p>\n

int door [6]<\/span>={1\uff0c2\uff0c3};<\/span><\/code><\/pre>\n

       \u521d\u59cb\u5316\u540e\uff0c\u6570\u7ec4door\u7684\u7ed3\u679c\u4e3a:door [0]=1\uff0cdoor [1]=2\uff0cdoor [2]=3\uff0cdoor [4]=0\uff0cdoor [5]=0\uff0cdoor [6]=0.\u9700\u8981\u6ce8\u610f\u7684\u662f<\/strong>\uff1a\u88ab\u521d\u59cb\u5316\u7684\u6570\u7ec4\u5143\u7d20\u90e8\u5206\u5fc5\u987b\u662f\u6570\u7ec4\u4e2d\u4ece\u7b2c\u4e8c\u4e2a\u5143\u7d20\u5f00\u59cb\u7684\u8fde\u7eed\u5e8f\u5217\u3002\u4f8b\u5982\uff0c\u4ee5\u4e0b\u8bed\u53e5\u662f\u9519\u8bef\u7684:<\/p>\n

int<\/span> window<\/span>[6<\/span>]={\n  \n  1<\/span>\uff0c\uff0c3<\/span>\uff0c4<\/span>\uff0c5<\/span>};\/*\u7b2c\u4e8c\u4e2a\u5143\u7d20\u672a\u8d4b\u503c*\/<\/span>\nint<\/span> window<\/span>[6<\/span>]={\uff0c\uff0c\uff0c3<\/span>};\/*\u7b2c\u4e00\u4e2a\u548c\u7b2c\u4e8c\u4e2a\u5143\u7d20\u4e3a\u8d4b\u503c*\/<\/span>\n<\/code><\/pre>\n

       \u5927\u90e8\u5206\u7684\u65f6\u5019\uff0c\u521d\u59cb\u5316\u7684\u503c\u5e76\u65e0\u7279\u6b8a\u610f\u4e49\uff0c\u53ea\u662f\u4e3a\u4e86\u9632\u6b62\u51fa\u73b0\u610f\u5916\u7684\u6570\u503c\u3002\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u4e00\u822c\u4f1a\u5c06\u53d8\u91cf\u521d\u59cb\u5316\u4e3a0\u62160.0\u3002\u800c\u5bf9\u4e8e\u8fd9\u79cd\u60c5\u51b5\u4e0b\u7684\u6570\u7ec4\u521d\u59cb\u5316\uff0c\u53ef\u4ee5\u7528\u7f16\u8bd1\u5668\u7684\u81ea\u52a8\u521d\u59cb\u5316\u7684\u7279\u6027\u6765\u7b80\u5316\u521d\u59cb\u5316\u503c\u5e8f\u5217\u3002\u4f8b\u5982:<\/p>\n

int<\/span> mouth [12<\/span>]={\n  \n  0<\/span>};\ndouble<\/span> degree[12<\/span>] = {\n  \n  0.0<\/span>};\nchar<\/span> ip[16<\/span>] = {\n  \n  0<\/span>};\n<\/code><\/pre>\n

\u5f62\u5f0f\u4e09<\/strong>
       \u521d\u59cb\u5316\u6570\u7ec4\u65f6\uff0c\u8fd8\u53ef\u4ee5\u5728\u5b9a\u4e49\u4e2d\u4e0d\u7ed9\u51fa\u5bb9\u91cf\u5927\u5c0f\uff0c\u5373\u8ba9\u5bb9\u91cf\u5927\u5c0f\u7531\u521d\u59cb\u5316\u503c\u5e8f\u5217\u7684\u4e2a\u6570\u51b3\u5b9a\u3002\u4e00\u822c\u60c5\u51b5\u4e0b\uff0c\u8fd9\u662f\u53ef\u884c\u4f46\u4e0d\u63a8\u8350\u7684\u65b9\u6cd5\u3002\u5176\u5f62\u5f0f\u5982\u4e0b\uff1a<\/p>\n

char<\/span> font[] = {\n  \n  'a'<\/span>,'b'<\/span>,'c'<\/span>,'d'<\/span>,'e'<\/span>,'f'<\/span>,'g'<\/span>};<\/code><\/pre>\n

\u7531\u4e8e\u521d\u59cb\u5316\u503c\u5e8f\u5217\u67097\u4e2achar\u578b\u503c\uff0c\u56e0\u6b64\uff0c\u6570\u7ec4font\u7684\u5bb9\u91cf\u4e3a7\u3002\u4e0a\u9762\u4ecb\u7ecd\u4e86\u4e09\u79cd\u6570\u7ec4\u521d\u59cb\u5316\u7684\u4e09\u79cd\u5f62\u5f0f\uff0c\u4e0b\u9762\u6765\u9a8c\u8bc1\u521d\u59cb\u5316\u7684\u7ed3\u679c\u3002\u5b9e\u73b0\u65b9\u6cd5\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n

#include<stdio.h><\/span>\n#define SIZE 5<\/span>\nint<\/span> main()\n{\n    int<\/span> arry1[SIZE] = {\n  \n  1<\/span>,2<\/span>,3<\/span>,4<\/span>,5<\/span>};   \/\/\u5b9a\u4e49\u5e76\u521d\u59cb\u5316\u6570\u7ec4arry1<\/span>\n    int<\/span> arry2[SIZE] = {\n  \n  0<\/span>};           \/\/\u5b9a\u4e49\u5e76\u521d\u59cb\u5316\u6570\u7ec4arry2<\/span>\n    int<\/span> arry3[] = {\n  \n  11<\/span>,22<\/span>,33<\/span>,44<\/span>,55<\/span>};  \/\/\u5b9a\u4e49\u5e76\u521d\u59cb\u5316\u6570\u7ec4arry3<\/span>\n    int<\/span> i = 0<\/span>;\n    int<\/span> j = 0<\/span>;\n    int<\/span> k = 0<\/span>;\n    for<\/span>(i=0<\/span>;i < SIZE; i++)\n    { \n       printf<\/span>(\"arry1[%d]=%2d \"<\/span>,i,arry1[i]);  \/\/\u8f93\u51faarry1\u7684\u503c<\/span>\n    }\n    printf<\/span>(\"\\n\"<\/span>);\n    for<\/span>( j = 0<\/span>;j < SIZE; j++)\n    { \n       printf<\/span>(\"arry2[%d]=%2d \"<\/span>,j,arry2[j]);  \/\/\u8f93\u51faarry2\u7684\u503c<\/span>\n    }\n    printf<\/span>(\"\\n\"<\/span>);\n    for<\/span>( k = 0<\/span>;k < SIZE; k++)\n    { \n       printf<\/span>(\"arry3[%d]=%2d \"<\/span>,k,arry3[k]);  \/\/\u8f93\u51faarry3\u7684\u503c<\/span>\n    }\n    printf<\/span>(\"\\n\"<\/span>);\n  return<\/span>;\n}<\/code><\/pre>\n

\u8fd0\u884c\u7ed3\u679c\uff1a\"\u5982\u4f55\u521d\u59cb\u5316\u6570\u7ec4
\u4ee3\u7801\u5206\u6790<\/strong>
\u25cf \u7b2c\u516d\u884c\uff0c\u5b9a\u4e49\u5e76\u521d\u59cb\u5316\u6570\u7ec4arry2\uff0c\u5bf9arry2\u521d\u59cb\u5316\u5e8f\u5217\u53ea\u5305\u542b\u4e00\u4e2a\u6574\u578b\u6570\u503c0\uff0c\u5176\u4f59\u7684\u5143\u7d20\u7531\u7f16\u8bd1\u5668\u81ea\u52a8\u8d4b\u503c0\u3002\u521d\u59cb\u5316\u540e\uff0c\u6570\u7ec4\u5143\u7d20\u5982\u4e0a\u8ff0\u8fd0\u884c\u7ed3\u679c\u7b2c\u4e8c\u884c\u6240\u793a\u3002
\u25cf \u7b2c11~24\u884c\uff0c\u4f7f\u7528\u4e09\u4e2a\u5faa\u73af\u5206\u522b\u5c06\u4e09\u4e2a\u6570\u7ec4\u7684\u5185\u5bb9\u8f93\u51fa\u3002
\u25cf \u7b2c21\u884c\uff0c\u53ef\u4ee5\u6539\u4e3afor\uff08k = 0;k < sizeof\uff08array3\uff09\/sizeof\uff08array3[ k ]\uff09; k++\uff09;
\u25cf \u7b2c23\u884c\uff0cprintf( \u201d array3[ %d ] = %2d \u201d , k,array3[ k ]);
       \u4e0a\u4f8b\u4e2d\u7b2c\u4e09\u4e2a\u6570\u7ec4\u901a\u8fc717\uff0c18\u884c\u4ee3\u7801\u8f93\u51fa\uff0c\u5176\u4e2d\uff0c\u68c0\u6d4b\u6570\u7ec4\u5927\u5c0f\u7528\u4e86 sizeof\uff08array3\uff09\/sizeof\uff08array3[ k ]\uff0c\u5b83\u8868\u793a\u6570\u7ec4 array3\u6240\u5360\u5b57\u8282\/\u4e00\u4e2a\u6574\u578b\u6570\u5b57\u6240\u5360\u7684\u5b57\u8282\u6570\uff0c\u5176\u76f8\u9664\u7ed3\u679c\u4e5f\u5c31\u662f\u6570\u7ec4\u5143\u7d20\u7684\u4e2a\u6570\uff0csizeof\uff08\uff09\u5bf9\u4e8e\u5176\u4ed6\u7c7b\u578b\u7684\u6570\u636e\u4e5f\u540c\u6837\u9002\u7528\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5982\u4f55\u521d\u59cb\u5316\u6570\u7ec4\u5206\u6790\uff1a\u5982\u679c\u76f4\u63a5\u8f93\u51fa\u672a\u521d\u59cb\u5316\u7684\u6570\u7ec4\u5143\u7d20\u503c\uff0c\u4ee5\u89c2\u5bdf\u672a\u521d\u59cb\u5316\u7684\u6570\u7ec4\uff0c\u5b9e\u73b0\u65b9\u6cd5\u4ee3\u7801\u5982\u4e0b\u6240\u793a\uff1a#include<stdio.h...","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[82],"tags":[],"_links":{"self":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/323"}],"collection":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/comments?post=323"}],"version-history":[{"count":0,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/323\/revisions"}],"wp:attachment":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/media?parent=323"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/categories?post=323"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/tags?post=323"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}