{"id":28,"date":"2010-06-22T10:56:18","date_gmt":"2010-06-22T02:56:18","guid":{"rendered":"http:\/\/comzyh.gicp.net\/myblog\/?p=28"},"modified":"2012-02-05T18:39:50","modified_gmt":"2012-02-05T10:39:50","slug":"%e8%bd%ac%e5%a4%9a%e5%85%b3%e9%94%ae%e5%ad%97%e7%9a%84%e5%bf%ab%e9%80%9f%e6%8e%92%e5%ba%8f","status":"publish","type":"post","link":"https:\/\/comzyh.com\/blog\/archives\/28\/","title":{"rendered":"[\u8f6c]\u591a\u5173\u952e\u5b57\u7684\u5feb\u901f\u6392\u5e8f"},"content":{"rendered":"<p>{<\/p>\n<p>\u4f5c\u8005\uff1a\u65f6\u51499154<\/p>\n<p><strong>\u5f53\u7136\u5e95\u4e0b\u7684C\u4ee3\u7801\u662f\u6211(Comzyh)\u5199\u7684<\/strong><\/p>\n<p><a href=\"http:\/\/hi.baidu.com\/time9154\">http:\/\/hi.baidu.com\/time9154<br \/>\n<\/a><br \/>\n}<\/p>\n<p>\u591a\u5173\u952e\u5b57\u7684\u5feb\u901f\u6392\u5e8f<\/p>\n<p>\u89e3\u51b3\u7c7b\u4f3c\u5982\u4e0b\u7684\u95ee\u9898\uff1a\u8f93\u5165n\u7ec4\u5750\u6807\uff08xi\uff0cyi\uff09\uff0c\u8981\u6c42\u6309xi\u7684\u5347\u5e8f\u6392\u5e8f\u540e\uff0c\u5bf9\u4e8exi=xj\uff08j&gt;i\uff09\uff0cyi~j\u5347\u5e8f\u6392\u5217<\/p>\n<p>\u5373\u53cc\u5173\u952e\u5b57\u6392\u5e8f\uff0c\u5148\u4fdd\u8bc1\u7b2c\u4e00\u5173\u952e\u5b57\u7684\u5347\u5e8f\uff0c\u5728\u7b2c\u4e00\u5173\u952e\u5b57\u4e00\u6837\u7684\u60c5\u51b5\u4e0b\u4fdd\u8bc1\u7b2c\u4e8c\u5173\u952e\u5b57\u7684\u5347\u5e8f<br \/>\n<!--more--><\/p>\n<pre lang='pascal'>var\r\na:array[0..maxn,1..2]of longint;\r\nn,i:longint;\r\n\r\nprocedure qsort(v1,v1:longint);\r\nvar i,j,mid1,mid2,temp:longint;\r\nbegin\r\ni:=v1; j:=v2;\r\nmid1:=a[(i+j) shr 1,1];\r\nmid2:=a[(i+j) shr 1,2];\r\nwhile i<j do\r\nbegin\r\nwhile (a[i,1]<mid1) or ((a[i,1]=mid1) and (a[i,2]<mid2)) do inc(i);\r\nwhile (a[j,1]>mid1) or ((a[j,1]=mid1) and (a[j,2]>mid2)) do dec(j);\r\nif i<=j then\r\nbegin\r\ntemp:=a[i,1]; a[i,1]:=a[j,1]; a[j,1]:=temp;\r\ntemp:=a[i,2]; a[i,2]:=a[j,2]; a[j,2]:=temp;\r\ninc(i); dec(j);\r\nend;\r\nend;\r\nif v1<j then qsort(v1,j);\r\nif i<v2 then qsort(i,v2);\r\nend; <\/pre>\n<p>\u591a\u5173\u952e\u5b57\u7684\u6392\u5e8f\u53ef\u4ee5\u4e00\u6b21\u7c7b\u63a8\uff0c\u6bd4\u5982\u518d\u52a0\u4e00\u4e2a\u7b2c\u4e09\u5173\u952e\u5b57Zi\uff08\u4fdd\u8bc1\u964d\u5e8f\uff09<\/p>\n<p>\u5373\u6539\u4e3a<\/p>\n<pre lang='pascal'>while (a[i,1]<mid1) or ((a[i,1]=mid1) and (a[i,2]<mid2)) or((a[i,1]=mid1) and (a[i,2]=mid2) and (a[i,3]>mid3)) do inc(i);\r\n\r\nwhile (a[j,1]>mid1) or ((a[j,1]=mid1) and (a[j,2]>mid2)) or((a[j,1]=mid1) and (a[j,2]=mid2) and (a[j,3]<mid3)) do dec(j);\r\n<\/pre>\n<p>\u4e0b\u9762\u7ed9\u4e00\u6bb5Comzyh\u7684C++\u7248\u672c<\/p>\n<pre lang='cpp'>\r\n\/*\r\nProgram:\u53cc\u5173\u952e\u5b57\u5feb\u901f\u6392\u5e8f\u6f14\u793a\u7a0b\u5e8f\r\nAuthor:Comzyh\r\n*\/\r\n#include <cstdio>\r\n#include <cstdlib>\r\nstruct data\r\n{\r\n       int a,b;\/\/\u53cc\u5173\u952e\u5b57\r\n};\r\ndata tab[1000],y;\/\/y:\u4ea4\u6362\u53d8\u91cf \r\nint N;\r\nvoid qsort(int b,int e);\r\nint main()\r\n{\r\n    int i;\r\n    printf(\"Please Enter number of cases:\"); \r\n    scanf(\"%d\",&N);\r\n    for (i=1;i<=N;i++)\r\n        scanf(\"%d%d\",&#038;tab[i].a,&#038;tab[i].b);\r\n    qsort(1,N);\r\n    printf(\"Sorting...\\n\");\r\n    for (i=1;i<=N;i++)\r\n        printf(\"%4d %4d\\n\",tab[i].a,tab[i].b);\r\n    system(\"pause\");\r\n}\r\nvoid qsort(int b,int e)\r\n{\r\n     int i=b,j=e;\r\n     data x=tab[(b+e)>>1];\r\n     while (i<j)\r\n     {\r\n           \/\/\u8fd9\u91cc\u662f\u6539\u8fc7\u7684\u6bd4\u8f83\u8bed\u53e5 \r\n           while (tab[i].a<x.a ||((tab[i].a ==x.a) &#038;&#038; (tab[i].b<x.b)))i++;\r\n           while (tab[j].a>x.a ||((tab[j].a ==x.a) && (tab[j].b>x.b)))j--;\r\n           if (i<=j)\r\n           {\r\n              y=tab[i];\r\n              tab[i]=tab[j];\r\n              tab[j]=y;\r\n              i++;j--;\r\n           }\r\n     }\r\n     if (b<j)qsort(b,j);\r\n     if (i<e)qsort(i,e);\r\n}\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>{ \u4f5c\u8005\uff1a\u65f6\u51499154 \u5f53\u7136\u5e95\u4e0b\u7684C\u4ee3\u7801\u662f\u6211(Comzyh)\u5199\u7684 http:\/\/hi.baidu.com\/ti [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[9,30],"tags":[26],"class_list":["post-28","post","type-post","status-publish","format-standard","hentry","category-9","category-non-solution","tag-26"],"jetpack_publicize_connections":[],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p6XQWE-s","jetpack-related-posts":[],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/comzyh.com\/blog\/wp-json\/wp\/v2\/posts\/28","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/comzyh.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/comzyh.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/comzyh.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/comzyh.com\/blog\/wp-json\/wp\/v2\/comments?post=28"}],"version-history":[{"count":2,"href":"https:\/\/comzyh.com\/blog\/wp-json\/wp\/v2\/posts\/28\/revisions"}],"predecessor-version":[{"id":672,"href":"https:\/\/comzyh.com\/blog\/wp-json\/wp\/v2\/posts\/28\/revisions\/672"}],"wp:attachment":[{"href":"https:\/\/comzyh.com\/blog\/wp-json\/wp\/v2\/media?parent=28"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/comzyh.com\/blog\/wp-json\/wp\/v2\/categories?post=28"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/comzyh.com\/blog\/wp-json\/wp\/v2\/tags?post=28"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}