{"id":262,"date":"2007-11-09T03:45:57","date_gmt":"2007-11-09T03:45:57","guid":{"rendered":"http:\/\/pchero21.com\/?p=262"},"modified":"2007-11-09T03:45:57","modified_gmt":"2007-11-09T03:45:57","slug":"%eb%a1%9c%eb%98%90-%ed%94%84%eb%a1%9c%ea%b7%b8%eb%9e%98%eb%b0%8d","status":"publish","type":"post","link":"http:\/\/pchero21.com\/?p=262","title":{"rendered":"\ub85c\ub610 \ud504\ub85c\uadf8\ub798\ubc0d"},"content":{"rendered":"<p>\/***************************************************************************<br \/>&nbsp;* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; Lotto.c<br \/>&nbsp;*<br \/>&nbsp;*&nbsp; Sun Nov&nbsp; 4 01:12:21 2007<br \/>&nbsp;*&nbsp; Copyright&nbsp; 2007&nbsp; pchero21<br \/>&nbsp;*&nbsp; pchero21@gmail.com<br \/>&nbsp;****************************************************************************\/<\/p>\n<p>\/*<br \/>&nbsp;*&nbsp; This program is free software; you can redistribute it and\/or modify<br \/>&nbsp;*&nbsp; it under the terms of the GNU General Public License as published by<br \/>&nbsp;*&nbsp; the Free Software Foundation; either version 2 of the License, or<br \/>&nbsp;*&nbsp; (at your option) any later version.<br \/>&nbsp;*<br \/>&nbsp;*&nbsp; This program is distributed in the hope that it will be useful,<br \/>&nbsp;*&nbsp; but WITHOUT ANY WARRANTY; without even the implied warranty of<br \/>&nbsp;*&nbsp; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.&nbsp; See the<br \/>&nbsp;*&nbsp; GNU General Public License for more details.<br \/>&nbsp;*<br \/>&nbsp;*&nbsp; You should have received a copy of the GNU General Public License<br \/>&nbsp;*&nbsp; along with this program; if not, write to the Free Software<br \/>&nbsp;*&nbsp; Foundation, Inc., 59 Temple Place &#8211; Suite 330, Boston, MA 02111-1307, USA.<br \/>&nbsp;*\/<br \/>&nbsp;<br \/>#include &lt;stdio.h&gt;<br \/>#include &lt;stdlib.h&gt;<br \/>#include &lt;time.h&gt;<\/p>\n<p>#define LOTTO_COUNT 6<br \/>#define LOTTO_MAX 45<br \/>#define NUM_LOTATE 100000<\/p>\n<p>struct Lotto_array {<br \/>&nbsp;&nbsp; &nbsp;int lotto_number;<br \/>&nbsp;&nbsp; &nbsp;int number_count;<br \/>};<\/p>\n<p>void quickSort(int low, int high, struct Lotto_array *a);<br \/>void swap(struct Lotto_array *a, struct Lotto_array *b);<br \/>void partition(int low, int high, int *pivotpoint, struct Lotto_array *S)<br \/>;<\/p>\n<p>int main()<br \/>{<br \/>&nbsp;&nbsp; &nbsp;int i, j, k, tmp[6];<br \/>&nbsp;&nbsp; &nbsp;struct Lotto_array lotto_array[LOTTO_MAX];<br \/>&nbsp;&nbsp; &nbsp;struct timespec timecheck;<br \/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<br \/>&nbsp;&nbsp; &nbsp;for(i = 0; i &lt; 45; i++) {<br \/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;lotto_array[i].lotto_number = i + 1;<br \/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;lotto_array[i].number_count = 0;<br \/>&nbsp;&nbsp; &nbsp;}<br \/>&nbsp;&nbsp; &nbsp;<br \/>&nbsp;&nbsp; &nbsp;for(i = 0; i &lt; NUM_LOTATE; i++) {<br \/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;clock_gettime(CLOCK_REALTIME, &amp;timecheck);<br \/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;srand((unsigned)timecheck.tv_nsec * 1000000000);<br \/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<br \/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;for(j = 0; j &lt; LOTTO_COUNT; j++) {<br \/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;tmp[j] = (rand() % 45);<br \/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<br \/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;for(k = 0; k &lt; j; k++) {<br \/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if(tmp[k] == tmp[j]) {<br \/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;j&#8211;;<br \/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;<br \/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br \/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br \/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}<br \/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<br \/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;for(j = 0; j &lt; LOTTO_COUNT; j++) {<br \/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;lotto_array[tmp[j]].number_count++;<br \/>&nbsp;&nbsp; &nbsp;\/\/ &nbsp; &nbsp; &nbsp; &nbsp;printf(&#8220;%d &#8220;, tmp[j]);<br \/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}<br \/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;putchar(&#8216;n&#8217;);<br \/>&nbsp;&nbsp; &nbsp;}<\/p>\n<p>&nbsp;&nbsp; &nbsp;quickSort(0, 44,lotto_array);<br \/>&nbsp;&nbsp; &nbsp;<\/p>\n<p>&nbsp;&nbsp; &nbsp;printf(&#8220;The Lotto number counting!!n&#8221;);<br \/>&nbsp;&nbsp; &nbsp;<br \/>&nbsp;&nbsp; &nbsp;for(i = 0; i &lt; LOTTO_MAX; i++) <br \/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;printf(&#8220;%d th : %d : %dn&#8221;, i + 1, lotto_array[i].lotto_number, lotto_array[i].number_count);<br \/>&nbsp;&nbsp; &nbsp;<br \/>&nbsp;&nbsp; &nbsp;return 0;<br \/>}<\/p>\n<p>void quickSort(int low, int high, struct Lotto_array *a)<br \/>{<br \/>&nbsp;&nbsp; &nbsp;int pivotpoint;<br \/>&nbsp;<br \/>&nbsp;&nbsp; &nbsp;if(high &gt; low) {<br \/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;partition(low, high, &amp;pivotpoint, a);<br \/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;quickSort(low, pivotpoint &#8211; 1, a);<br \/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;quickSort(pivotpoint + 1, high, a);<br \/>&nbsp;&nbsp; &nbsp;}<br \/>}<\/p>\n<p>void partition(int low, int high, int *pivotpoint, struct Lotto_array *S)<br \/>{<br \/>&nbsp;&nbsp; &nbsp;int i, j;<br \/>&nbsp;&nbsp; &nbsp;int pivotitem;<\/p>\n<p>&nbsp;&nbsp; &nbsp;pivotitem = S[low].number_count;<br \/>&nbsp;&nbsp; &nbsp;j = low;<br \/>&nbsp;&nbsp; &nbsp;for(i = low + 1; i &lt;= high; i++) {<br \/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if(S[i].number_count &gt; pivotitem) {<br \/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;j++;<br \/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;swap(&amp;S[i], &amp;S[j]);<br \/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}<br \/>&nbsp;&nbsp; &nbsp;}<br \/>&nbsp;&nbsp; &nbsp;*pivotpoint = j;<br \/>&nbsp;&nbsp; &nbsp;swap(&amp;S[low], &amp;S[*pivotpoint]);<br \/>}<br \/>&nbsp;<br \/>void swap(struct Lotto_array *a, struct Lotto_array *b)<br \/>{<br \/>&nbsp;&nbsp; &nbsp;struct Lotto_array temp;<br \/>&nbsp;&nbsp; &nbsp;temp = *a;<br \/>&nbsp;&nbsp; &nbsp;*a = *b;<br \/>&nbsp;&nbsp; &nbsp;*b = temp;<br \/>}<\/p>\n<p>\ub85c\ub610\ub97c 10\ub9cc \uac8c\uc784\uc744 \ud574\uc11c \uac00\uc7a5 \ub9ce\uc774 Hit \ud55c \ub85c\ub610 \ubc88\ud638 \uc21c\uc11c\ub300\ub85c \ucd9c\ub825\ud558\ub294 \ud504\ub85c\uadf8\ub7a8.<br \/>\ud37c\uac00\uc2e4\ub54c \ucd9c\ucc98\ub294 \ubc1d\ud600\uc8fc\uc138\uc694.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\/***************************************************************************&nbsp;* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; Lotto.c&nbsp;*&nbsp;*&nbsp; Sun Nov&nbsp; 4 01:12:21 2007&nbsp;*&nbsp; Copyright&nbsp; 2007&nbsp; pchero21&nbsp;*&nbsp; pchero21@gmail.com&nbsp;****************************************************************************\/ \/*&nbsp;*&nbsp; This program is free software; you can redistribute it and\/or modify&nbsp;*&nbsp; it under the terms of the GNU General Public License as published &hellip; <a href=\"http:\/\/pchero21.com\/?p=262\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[33],"tags":[],"_links":{"self":[{"href":"http:\/\/pchero21.com\/index.php?rest_route=\/wp\/v2\/posts\/262"}],"collection":[{"href":"http:\/\/pchero21.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/pchero21.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/pchero21.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/pchero21.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=262"}],"version-history":[{"count":0,"href":"http:\/\/pchero21.com\/index.php?rest_route=\/wp\/v2\/posts\/262\/revisions"}],"wp:attachment":[{"href":"http:\/\/pchero21.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=262"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/pchero21.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=262"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/pchero21.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=262"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}