{"id":12072,"date":"2017-05-18T00:00:00","date_gmt":"2017-05-17T16:00:00","guid":{"rendered":"https:\/\/fgchen.com\/wpedu2\/2017\/05\/18\/%e3%80%90-%e7%a8%8b%e5%bc%8f%e8%a8%ad%e8%a8%88%e3%80%91%e8%a8%98%e6%86%b6%e9%81%8a%e6%88%b2\/"},"modified":"2026-03-30T14:49:10","modified_gmt":"2026-03-30T06:49:10","slug":"%e3%80%90-%e7%a8%8b%e5%bc%8f%e8%a8%ad%e8%a8%88%e3%80%91%e8%a8%98%e6%86%b6%e9%81%8a%e6%88%b2","status":"publish","type":"post","link":"https:\/\/fgchen.com\/wpedu\/2017\/05\/%e3%80%90-%e7%a8%8b%e5%bc%8f%e8%a8%ad%e8%a8%88%e3%80%91%e8%a8%98%e6%86%b6%e9%81%8a%e6%88%b2\/","title":{"rendered":"\u3010\u7a0b\u5f0f\u8a2d\u8a08-C#\u3011\u8a18\u61b6\u904a\u6232"},"content":{"rendered":"\n\n<span style=\"font-size: 14pt\"><strong>\u3010\u8a2d\u8a08\u57fa\u790e\u4e00\uff1a\u6392\u5217\u5716\u7247\u3001\u767c\u724c\u3001\u6d17\u724c\u3011<\/strong><\/span>\n\n<pre class=\"theme:vs2012 lang:c# decode:true \">using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\nnamespace plateDealing\n{\n    class Program\n    {\n        static void Main(string[] args)\n        {\n            Random rnd = new Random();\n            int[] plateHoles = new int[16];\n            for (int i = 0; i &lt;= 7; i++) \/\/\u5c072\u526f\u724c1~8\u7de8\u865f\u7684\u724c\u653e\u57280~15\u7de8\u865f\u7684\u4f4d\u7f6e\u4e0a\n            {\n                plateHoles[i] = i + 1;\n                plateHoles[i + 8] = i + 1;\n            }\n            for (int k = 1; k &lt;= 10; k++) \/\/10\u526f\u724c\n            {\n                Console.Write(\"\u7b2c{0:D2}\u526f\u724c\uff1a\", k);\n                for (int i = 0; i &lt;= 15; i++) \/\/\u5c07\u6bcf1\u500b\u4f4d\u7f6e\u7684\u724c\u968f\u6a5f\u7684\u548c\u4efb\u4e00\u4f4d\u7f6e\u7684\u724c\u9032\u884c\u4ea4\u63db\n                {\n                    int rndHole = rnd.Next(0, 15); \/\/\u4efb\u9078\u4e00\u500b\u4f4d\u7f6e\uff0c\u9032\u884c\u724c\u7684\u4ea4\u63db\n                    int temp = plateHoles[i];\n                    plateHoles[i] = plateHoles[rndHole];\n                    plateHoles[rndHole] = temp;\n                }\n                for (int i = 0; i &lt;= 15; i++) \/\/\u5370\u51fa\u724c\n                {\n                    Console.Write(plateHoles[i] + \"   \");\n                }\n                Console.WriteLine();\n            }\n            Console.ReadKey();\n        }\n    }\n}\n<\/pre>\n\n<a href=\"http:\/\/www.fgchen.com\/wp\/%e3%80%90-%e7%a8%8b%e5%bc%8f%e8%a8%ad%e8%a8%88%e3%80%91%e8%a8%98%e6%86%b6%e9%81%8a%e6%88%b2\/flipmatch-1\/\" rel=\"attachment wp-att-5170\"><img fetchpriority=\"high\" decoding=\"async\" class=\"size-full wp-image-5170 aligncenter\" src=\"http:\/\/www.fgchen.com\/wp\/wp-content\/uploads\/2017\/05\/FlipMatch-1.jpg\" alt=\"\" width=\"609\" height=\"184\" \/><\/a>\n\u4e0a\u9762\u7684\u7a0b\u5f0f\u5be6\u73fe\u4ee5\u4e0b\u7684\u60f3\u6cd5\uff1a\n\u60f3\u50cf\u4f60\u67092\u526f\u724c\uff0c\u54048\u5f35\uff0c\u7de8\u865f1~8\uff0c\u4e00\u958b\u59cb\u5148\u628a\u90192\u526f\u724c\u9806\u5e8f\u5730\u653e\u572816\u500b\u683c\u5b50(\u9663\u5217)\uff0c\u7136\u5f8c\u518d\u6d17\u724c (\u4f4d\u7f6e\u4ea4\u63db\u7684\u610f\u601d)\u3002\n\u53c3\u8003\u4f5c\u6cd5<span class=\"text_exposed_show\">\n1\uff0e\u5148\u5c072\u526f\u724c\u54041~8\u7de8\u865f\u7684\u724c\u653e\u572816\u500b\u4f4d\u7f6e\u4e0a\n2\uff0e\u5f9e\u7b2c1\u5f35\u724c\u958b\u59cb\uff0c\u8207\u4efb\u9078\u4e00\u500b\u4f4d\u7f6e\u7684\u724c\u4ea4\u63db (\u6253\u4e82\u724c\uff0c\u5c31\u50cf\u6d17\u724c\u7684\u610f\u601d)<\/span>\n\n<div class=\"text_exposed_show\">\n\u6392\u51fa\u4f86\u7684\u724c\uff0c\u5c31\u662f\u6bcf\u4e00\u5f35\u5716\u7684\u4f4d\u7f6e\u3002\n<\/div>\n\n<span style=\"font-size: 18pt\">\u3010\u7a0b\u5f0f\u78bc\u3011<a href=\"http:\/\/www.fgchen.com\/wp\/%e3%80%90-%e7%a8%8b%e5%bc%8f%e8%a8%ad%e8%a8%88%e3%80%91%e8%a8%98%e6%86%b6%e9%81%8a%e6%88%b2\/flipmatchgame\/\" rel=\"attachment wp-att-5230\">FlipMatchGame<\/a><\/span>\n\n<pre class=\"theme:vs2012 lang:c# decode:true\">using System;\nusing System.Collections.Generic;\nusing System.ComponentModel;\nusing System.Data;\nusing System.Drawing;\nusing System.Linq;\nusing System.Text;\nusing System.Windows.Forms;\nnamespace WindowsFormsApplication1\n{\n    public partial class Form1 : Form\n    {\n        \/\/PicNames\u9019\u500b\u4e8c\u7dad\u9663\u5217\u7528\u4f86\u5efa\u7acb\u6240\u6709\u5361\u7247\u5728\u8cc7\u6e90\u88cf\u7684\u540d\u7a31\uff0c\u6211\u7528\u4e8c\u7dad\u9663\u5217\uff0c\u5217\u662f\"\u82b1\u8272\"\uff0c\u884c\u662f\u6578\u5b57\u548cj~k\n        String[,] PicNames = {\n                             { \"ace_of_spades\", \"_2_of_spades\", \"_3_of_spades\", \"_4_of_spades\", \"_5_of_spades\", \"_6_of_spades\", \"_7_of_spades\", \"_8_of_spades\", \"_9_of_spades\", \"_10_of_spades\", \"jack_of_spades\", \"queen_of_spades\", \"king_of_spades\"},\n                             { \"ace_of_hearts\", \"_2_of_hearts\", \"_3_of_hearts\", \"_4_of_hearts\", \"_5_of_hearts\", \"_6_of_hearts\", \"_7_of_hearts\", \"_8_of_hearts\", \"_9_of_hearts\", \"_10_of_hearts\", \"jack_of_hearts\", \"queen_of_hearts\", \"king_of_hearts\"},\n                             { \"ace_of_diamonds\", \"_2_of_diamonds\", \"_3_of_diamonds\", \"_4_of_diamonds\", \"_5_of_diamonds\", \"_6_of_diamonds\", \"_7_of_diamonds\", \"_8_of_diamonds\", \"_9_of_diamonds\", \"_10_of_diamonds\", \"jack_of_diamonds\", \"queen_of_diamonds\", \"king_of_diamonds\"},\n                             { \"ace_of_clubs\", \"_2_of_clubs\", \"_3_of_clubs\", \"_4_of_clubs\", \"_5_of_clubs\", \"_6_of_clubs\", \"_7_of_clubs\", \"_8_of_clubs\", \"_9_of_clubs\", \"_10_of_clubs\", \"jack_of_clubs\", \"queen_of_clubs\", \"king_of_clubs\"}\n                             };\n        String[] Cards = {\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"};\n        Random randomNums;\n        PictureBox n1 = null, n2 = null; \/\/\u5206\u5225\u6307\u5411\u7b2c1\u5f35\u8207\u7b2c2\u5f35\u7ffb\u724c\n        String s1 = null, s2 = null; \/\/\u8a18\u9304\u7ffb\u724c\u7b2c1\u5f35\u8207\u7b2c2\u5f35\u7684\u6587\u5b57\uff0c\u7528\u4f86\u6bd4\u8f03\u7528\n        public Form1()\n        {\n            InitializeComponent();\n            randomNums = new Random(); \/\/\u5efa\u7acb\u4e82\u6578\u7269\u4ef6\n            prepareCards(); \/\/\u6d17\u724c\n        }\n        private void prepareCards() \/\/\u7522\u751f12\u5f35\u5361\uff0c\u5176\u4e2d\u5f8c6\u5f35\u662f\u8ddf\u524d\u97626\u5f35\u4e00\u6a23\uff0c\u518d\u5c07\u5176\u91cd\u6392\n        {\n            int i;\n            int row, col; \/\/\u64b2\u514b\u724c\u7d44\uff0c\u70ba2\u7dad\u9663\u5217\uff0c\u7528\u90192\u500b\u8b8a\u6578\u4f86\u5b58\u53d6\u6b64\u724c\u7d44\u9663\u5217\u7684\u724c\n            bool isRepeat;\n            for (i = 0; i &lt;= 5; i++)\/\/\u53ea\u6293\u524d6\u5f35\u724c\n            {\n                do\n                {\n                    isRepeat = false; \/\/\u6b64\u8b8a\u6578\u7528\u4f86\u5224\u8b80\u662f\u5426\u62bd\u51fa\u7684\u724c\u6709\u91cd\u8986\uff0c\u9810\u8a2dfalse\u2026\uff0c\u627e\u5230\u91cd\u8907\u7684\u724c\u4e4b\u5f8c\u8a2d\u70batrue(\u7e7c\u7e8c\u62bd\u724c\u2026)\n                    \/\/\u4e0b\u9762\u4e8c\u884c\u5be6\u73fe\u96a8\u6a5f\u62bd\u4e00\u5f35\u724c\u7684\u6982\u5ff5\n                    row = randomNums.Next(0, 4); \/\/\u7522\u751f0~3\u7684\u96a8\u6a5f\u6574\u6578\n                    col = randomNums.Next(0, 13); \/\/\u7522\u751f0~12\u7684\u96a8\u6a5f\u6574\u6578\n                    \/\/\u62bd\u724c\u5f8c\uff0c\u5fc5\u9808\u6aa2\u67e5\u6b64\u724c\u662f\u5426\u8ddf\u4e4b\u524d\u62bd\u51fa\u7684\u724c\u6709\u91cd\u8986\n                    for (int j = i - 1; j &gt;= 0; j--)\/\/\u770b\u65b0\u6293\u7684\u724c\u662f\u5426\u548c\u524d\u9762\u7684\u724c\u6709\u91cd\u8907\n                    {\n                        if (Cards[j].Equals(PicNames[row, col]))\n                        {\n                            isRepeat = true; break; \/\/\u82e5\u767c\u73fe\u6709\u91cd\u8907\u7684\u724c\uff0c\u8a2d\u5b9aisRepeat\u70batrue\uff0c\u96e2\u958bfor\uff0c\u8b93\u5916\u5c64\u7684do-while\u91cd\u8907\uff0c\u518d\u96a8\u6a5f\u62bd\u4e00\u5f35\u724c\u2026\n                        }\n                    }\n                } while (isRepeat);\n                \/\/\u62bd\u597d\u724c\u4e4b\u5f8c\uff0c\u628a\u724c\u653e\u5165Cards\u9663\u5217\u4e2d\n                Cards[i] = PicNames[row, col]; Cards[i+6] = PicNames[row, col]; \/\/\u4e00\u6b21\u4e8c\u5f35\u724c\n            }\n            for (i = 0; i &lt;= 11; i++) \/\/\u6253\u4e82\/\u91cd\u639212\u5f35\u724c\n            {\n                string temp = Cards[i];\n                int a = randomNums.Next(0, 12); \/\/\u4efb\u627e\u4e00\u4f4d\u7f6e\u4f86\u9032\u884c\u724c\u7684\u4ea4\u63db\n                Cards[i] = Cards[a];\n                Cards[a] = temp;\n            }\n        }\n        private void pictureBox_Click(object sender, EventArgs e)\n        {\n            PictureBox pb = (PictureBox)sender;\n            String s = pb.Name.Replace(\"pictureBox\", \"\");\n            \/\/\u628a\u5143\u4ef6\u7684\u540d\u5b57pictureBox1\u4e2d\u7684pictureBox\u53bb\u6389\uff0c\u8cf8\u4e0b\u6578\u5b57\u7684\u90e8\u4efd\uff0c\u53d6\u5f971~12\u7684\u6578\u5b57\u5b57\u4e32\n            \/\/\u4e0a\u9762\u9019\u884c\u7684\u76ee\u7684\u662f\u60f3\u8981\u77e5\u9053\u662f\u90a3\u4e00\u500bPictureBox\u88ab\u9ede\u64ca\u4e861~12\u500b\n            int index = Int32.Parse(s);\n            pb.Image = (Image)Properties.Resources.ResourceManager.GetObject(Cards[index-1]);\n            if (n1 == null) \/\/\u7ffb\u7b2c1\u5f35\u724c\u7684\u6642\u5019\n            {\n                n1 = pb; pb.Enabled = false; \/\/\u7528n1\u6307\u5411\u7ffb\u51fa\u4f86\u7684\u724c\u7684pictureBox, \u4e26\u5c07\u8a72pictureBox\u8a2d\u70ba\u4e0d\u4f5c\u7528\uff0c\u4ee5\u9632\u6b62\u518d\u6309\u8a72pictureBox\n                s1 = Cards[index - 1]; \/\/s1\u5b57\u4e32\u7528\u4f86\u8a18\u9304\u7b2c1\u5f35\u724c\u7684\u6587\u5b57\n            }\n            else \/\/\u7ffb\u7b2c2\u5f35\u724c\n            {\n                n2 = pb; n2.Enabled = false; \/\/\u540c\u7b2c1\u5f35\u724c\u4e00\u6a23\uff0c\u6b64\u90e8\u4efd\u4fc2\u8655\u7406\u7b2c2\u5f35\u724c\n                s2 = Cards[index - 1];\n                if (s1 != s2) \/\/\u6bd4\u8f03\u7ffb\u51fa\u4f86\u76842\u5f35\u724c\uff0c\u82e5\u4e0d\u4e00\u6a23\uff0c\u5247\u84cb\u724c\uff0c\u91cd\u65b0\u555f\u52d5\u4e8c\u5f35\u5361\u7684\u4f5c\u7528\u2026\n                {\n                    System.Threading.Thread.Sleep(1000); \/\/delay1\u79d2\uff0c\u8b93\u73a9\u5bb6\u53ef\u4ee5\u770b\u51fa\u724c\u88ab\u84cb\u4f4f\n                    n1.Image = Properties.Resources.black_joker; \/\/\u628a2\u5f35\u724c\u518d\u5ea6\u7528\u9b3c\u724c\u84cb\u4e0a\n                    n2.Image = n1.Image; \/\/\u7b2c2\u5f35\u724c\u4e5f\u662f\u7528\u9b3c\u724c\u4f86\u84cb\u4e0a\n                    n1.Enabled = true; n2.Enabled = true;\/\/\u82e5\u7ffb\u51fa\u4f86\u76842\u5f35\u724c\u4e0d\u4e00\u6a23\uff0c\u8a722\u5f35\u724c\u84cb\u4e0a\u5f8c\u518d\u8a2denabled\u70batrue\n                }\n                \/\/n1~n2\u3001s1~s2\u518d\u8a2d\u70banull\uff0c\u91cd\u65b0\u9032\u884c\u7ffb\u724c\u5224\u65b7\n                n1 = null; n2 = null;\n                s1 = null; s2 = null;\n            }\n        }\n    }\n}\n<\/pre>\n\n&nbsp;","protected":false},"excerpt":{"rendered":"<p>\u3010\u8a2d\u8a08\u57fa\u790e\u4e00\uff1a\u6392\u5217\u5716\u7247\u3001\u767c\u724c\u3001\u6d17\u724c\u3011 using System; using S &hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","fifu_image_url":"","fifu_image_alt":"","footnotes":""},"categories":[266],"tags":[147,148],"class_list":["post-12072","post","type-post","status-publish","format-standard","hentry","category-266","tag-flipmatch-game","tag-148"],"_links":{"self":[{"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/posts\/12072","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/comments?post=12072"}],"version-history":[{"count":1,"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/posts\/12072\/revisions"}],"predecessor-version":[{"id":13479,"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/posts\/12072\/revisions\/13479"}],"wp:attachment":[{"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/media?parent=12072"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/categories?post=12072"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/tags?post=12072"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}