{"id":76534,"date":"2024-01-12T09:26:52","date_gmt":"2024-01-12T01:26:52","guid":{"rendered":"\/\/www.viralrail.com\/?p=76534"},"modified":"2024-01-12T09:26:52","modified_gmt":"2024-01-12T01:26:52","slug":"cxkzjgjqzyx","status":"publish","type":"post","link":"\/\/www.viralrail.com\/blog\/76534.html","title":{"rendered":"\u7a0b\u5e8f\u63a7\u5236\u7ed3\u6784\u53ca\u5176\u91cd\u8981\u6027"},"content":{"rendered":"

  \u7a0b\u5e8f\u7684\u63a7\u5236\u7ed3\u6784\u662f\u7f16\u7a0b\u4e2d\u7684\u6838\u5fc3\u5173\u952e\u8bcd\u4e4b\u4e00\u3002\u4eca\u5929\u6211\u4eec\u5c06\u4ecb\u7ecd\u7a0b\u5e8f\u63a7\u5236\u7ed3\u6784\u7684\u4f5c\u7528\u548c\u91cd\u8981\u6027\uff0c\u5e76\u63a2\u8ba8\u5176\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\u7684\u4ef7\u503c\u3002<\/p>\n

\u6761\u4ef6\u8bed\u53e5\uff1a\u7a0b\u5e8f\u6267\u884c\u7684\u903b\u8f91\u5206\u652f<\/h2>\n

  \u6761\u4ef6\u8bed\u53e5\u662f\u7a0b\u5e8f\u63a7\u5236\u7ed3\u6784\u4e2d\u7684\u91cd\u8981\u7ec4\u6210\u90e8\u5206\u3002\u901a\u8fc7\u6761\u4ef6\u8bed\u53e5\uff0c\u7a0b\u5e8f\u53ef\u4ee5\u6839\u636e\u4e0d\u540c\u7684\u903b\u8f91\u6761\u4ef6\u6267\u884c\u4e0d\u540c\u7684\u64cd\u4f5c\u3002\u5e38\u89c1\u7684\u6761\u4ef6\u8bed\u53e5\u5305\u62ecif\u8bed\u53e5\u3001else\u8bed\u53e5\u548cswitch\u8bed\u53e5\u3002\u5728\u5b9e\u9645\u7f16\u7a0b\u4e2d\uff0c\u5408\u7406\u8fd0\u7528\u6761\u4ef6\u8bed\u53e5\u53ef\u4ee5\u63d0\u9ad8\u7a0b\u5e8f\u7684\u7075\u6d3b\u6027\u548c\u53ef\u8bfb\u6027\uff0c\u4f7f\u7a0b\u5e8f\u80fd\u591f\u6839\u636e\u4e0d\u540c\u60c5\u51b5\u8fdb\u884c\u667a\u80fd\u5316<\/a>\u5904\u7406\u3002<\/p>\n

  if\u8bed\u53e5\uff1a\u6839\u636e\u6761\u4ef6\u6267\u884c\u4e0d\u540c\u64cd\u4f5c<\/h3>\n

  if\u8bed\u53e5\u662f\u6700\u57fa\u672c\u7684\u6761\u4ef6\u8bed\u53e5\u4e4b\u4e00\uff0c\u5b83\u901a\u8fc7\u5224\u65ad\u6761\u4ef6\u662f\u5426\u6210\u7acb\u6765\u786e\u5b9a\u7a0b\u5e8f\u6267\u884c\u7684\u8def\u5f84\u3002\u4f8b\u5982\uff1a<\/p>\n

 if (\u6761\u4ef6) {<\/p>   \/\/ \u6761\u4ef6\u6210\u7acb\u65f6\u6267\u884c\u7684\u64cd\u4f5c<\/p> } else {<\/p>   \/\/ \u6761\u4ef6\u4e0d\u6210\u7acb\u65f6\u6267\u884c\u7684\u64cd\u4f5c<\/p> }<\/p><\/code><\/pre>\n

  switch\u8bed\u53e5\uff1a\u591a\u4e2a\u6761\u4ef6\u7684\u903b\u8f91\u5206\u652f<\/h3>\n

  switch\u8bed\u53e5\u9002\u7528\u4e8e\u9700\u8981\u6839\u636e\u4e0d\u540c\u53d6\u503c\u6267\u884c\u4e0d\u540c\u64cd\u4f5c\u7684\u60c5\u51b5\u3002\u5b83\u7684\u7ed3\u6784\u6e05\u6670\uff0c\u6613\u4e8e\u9605\u8bfb\u548c\u7ef4\u62a4\uff0c\u5e76\u4e14\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\u6027\u80fd\u66f4\u597d\u3002\u4f8b\u5982\uff1a<\/p>\n

 switch (\u8868\u8fbe\u5f0f) {<\/p>   case \u503c1:<\/p>     \/\/ \u6267\u884c\u64cd\u4f5c1<\/p>     break;<\/p>   case \u503c2:<\/p>     \/\/ \u6267\u884c\u64cd\u4f5c2<\/p>     break;<\/p>   default:<\/p>     \/\/ \u9ed8\u8ba4\u60c5\u51b5\u4e0b\u6267\u884c\u7684\u64cd\u4f5c<\/p> }<\/p><\/code><\/pre>\n

\u5faa\u73af\u7ed3\u6784\uff1a\u91cd\u590d\u6267\u884c\u6307\u5b9a\u64cd\u4f5c<\/h2>\n

  \u5faa\u73af\u7ed3\u6784\u662f\u7a0b\u5e8f\u63a7\u5236\u7ed3\u6784\u4e2d\u7684\u53e6\u4e00\u4e2a\u91cd\u8981\u7ec4\u6210\u90e8\u5206\u3002\u901a\u8fc7\u5faa\u73af\u7ed3\u6784\uff0c\u7a0b\u5e8f\u53ef\u4ee5\u91cd\u590d\u6267\u884c\u6307\u5b9a\u7684\u64cd\u4f5c\uff0c\u76f4\u5230\u6ee1\u8db3\u9000\u51fa\u6761\u4ef6\u3002\u5e38\u89c1\u7684\u5faa\u73af\u7ed3\u6784\u5305\u62ecfor\u5faa\u73af\u3001while\u5faa\u73af\u548cdo-while\u5faa\u73af\u3002\u5408\u7406\u8fd0\u7528\u5faa\u73af\u7ed3\u6784\u53ef\u4ee5\u5b9e\u73b0\u9ad8\u6548\u7684\u6570\u636e\u5904\u7406\u548c\u7b97\u6cd5\u5b9e\u73b0\u3002<\/p>\n

  for\u5faa\u73af\uff1a\u6307\u5b9a\u6b21\u6570\u7684\u5faa\u73af\u64cd\u4f5c<\/h3>\n

  for\u5faa\u73af\u9002\u7528\u4e8e\u9700\u8981\u6307\u5b9a\u6b21\u6570\u7684\u5faa\u73af\u64cd\u4f5c\u3002\u5b83\u7684\u7ed3\u6784\u6e05\u6670\uff0c\u9002\u7528\u4e8e\u5927\u90e8\u5206\u9700\u8981\u660e\u786e\u5faa\u73af\u6b21\u6570\u7684\u60c5\u51b5\u3002\u4f8b\u5982\uff1a<\/p>\n

 for (\u521d\u59cb\u5316; \u6761\u4ef6; \u66f4\u65b0) {<\/p>   \/\/ \u5faa\u73af\u6267\u884c\u7684\u64cd\u4f5c<\/p> }<\/p><\/code><\/pre>\n

  while\u5faa\u73af\uff1a\u6ee1\u8db3\u6761\u4ef6\u624d\u6267\u884c\u7684\u5faa\u73af\u64cd\u4f5c<\/h3>\n

  while\u5faa\u73af\u9002\u7528\u4e8e\u9700\u8981\u5728\u6ee1\u8db3\u6761\u4ef6\u65f6\u5faa\u73af\u6267\u884c\u64cd\u4f5c\u7684\u60c5\u51b5\u3002\u5b83\u5bf9\u5faa\u73af\u6267\u884c\u6761\u4ef6\u6ca1\u6709\u4e25\u683c\u9650\u5236\uff0c\u9002\u7528\u6027\u5e7f\u6cdb\u3002\u4f8b\u5982\uff1a<\/p>\n

 while (\u6761\u4ef6) {<\/p>   \/\/ \u5faa\u73af\u6267\u884c\u7684\u64cd\u4f5c<\/p> }<\/p><\/code><\/pre>\n

\u603b\u7ed3<\/h2>\n

  \u7a0b\u5e8f\u7684\u63a7\u5236\u7ed3\u6784\u662f\u7f16\u7a0b\u4e2d\u7684\u6838\u5fc3\u6982\u5ff5\uff0c\u6761\u4ef6\u8bed\u53e5\u548c\u5faa\u73af\u7ed3\u6784\u4f5c\u4e3a\u63a7\u5236\u7ed3\u6784\u7684\u91cd\u8981\u7ec4\u6210\u90e8\u5206\uff0c\u80fd\u591f\u5e2e\u52a9\u7a0b\u5e8f\u5b9e\u73b0\u903b\u8f91\u5206\u652f\u3001\u5faa\u73af\u6267\u884c\u7b49\u529f\u80fd\u3002<\/strong>\u7a0b\u5e8f\u5458\u5e94\u5f53\u6df1\u523b\u7406\u89e3\u63a7\u5236\u7ed3\u6784\u7684\u4f5c\u7528\u548c\u539f\u7406\uff0c\u5e76\u5728\u5b9e\u9645\u7f16\u7a0b\u4e2d\u5408\u7406\u8fd0\u7528\uff0c\u4ee5\u5b9e\u73b0\u9ad8\u6548\u3001\u7075\u6d3b\u3001\u53ef\u7ef4\u62a4\u7684\u7a0b\u5e8f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u7a0b\u5e8f\u7684\u63a7\u5236\u7ed3\u6784\u662f\u7f16\u7a0b\u4e2d\u7684\u6838\u5fc3\u5173\u952e\u8bcd\u4e4b\u4e00\u3002\u672c\u6587\u5c06\u4ecb\u7ecd\u7a0b\u5e8f\u63a7\u5236\u7ed3\u6784\u7684\u4f5c\u7528\u548c\u91cd\u8981\u6027\uff0c\u5e76\u63a2\u8ba8\u5176\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\u7684\u4ef7\u503c\u3002\u6761\u4ef6\u8bed\u53e5\uff1a\u7a0b\u5e8f\u6267\u884c\u7684\u903b\u8f91\u5206\u652f\u6761\u4ef6\u8bed\u53e5\u662f\u7a0b\u5e8f\u63a7\u5236\u7ed3\u6784\u4e2d\u7684\u91cd<\/p>\n","protected":false},"author":1,"featured_media":64183,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-global-header-display":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","footnotes":""},"categories":[36],"tags":[305],"class_list":["post-76534","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","tag-dzjs"],"_links":{"self":[{"href":"\/\/www.viralrail.com\/wp-json\/wp\/v2\/posts\/76534"}],"collection":[{"href":"\/\/www.viralrail.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"\/\/www.viralrail.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"\/\/www.viralrail.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"\/\/www.viralrail.com\/wp-json\/wp\/v2\/comments?post=76534"}],"version-history":[{"count":0,"href":"\/\/www.viralrail.com\/wp-json\/wp\/v2\/posts\/76534\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"\/\/www.viralrail.com\/wp-json\/wp\/v2\/media\/64183"}],"wp:attachment":[{"href":"\/\/www.viralrail.com\/wp-json\/wp\/v2\/media?parent=76534"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"\/\/www.viralrail.com\/wp-json\/wp\/v2\/categories?post=76534"},{"taxonomy":"post_tag","embeddable":true,"href":"\/\/www.viralrail.com\/wp-json\/wp\/v2\/tags?post=76534"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}