#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
    int i, j;
    int ret;
    int a[6], count[7];
    int bingo[6], cc;
    FILE* stream;
 
    for (i = 6; i >= 0; i--)
        count[i] = 0;
 
    printf("Bingo numbers:");
    scanf("%2d %2d %2d %2d %2d %2d",
                &bingo[0], &bingo[1], &bingo[2], &bingo[3], &bingo[4], &bingo[5]);
 
    stream=fopen("lotto.txt", "r");
    ret=fscanf(stream,"%2d %2d %2d %2d %2d %2d\n",
                &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]);
 
    while (ret == 6)
    {      
        printf("%2d %2d %2d %2d %2d %2d\n",
                a[0], a[1], a[2], a[3], a[4], a[5]);
        //compare two array
        cc = 0;
        for (i=0; i<6; i++)
        {
            for (j=0; j<6;j++)
            {
                if (bingo[i]==a[j])
                   cc++;
            }
        }
        count[cc]++;
        ret=fscanf(stream,"%2d %2d %2d %2d %2d %2d\n",
                &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]);
    }
    fclose(stream);
    for (i = 6; i >= 0; i--)
        printf("Match %d numbers: %d \n", i, count[i]);
 
    return 0;
}

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Tags: , ,

This entry was posted on 星期三, 十一月 28th, 2012 at 10:41:12 and is filed under 101(上)程式設計(一). You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

14 Trackbacks/Pings

  1. orlando    七月 31 2014 / 12下午:

    press@neva.breezy” rel=”nofollow”>.…

    tnx for info!…

  2. Travis    八月 26 2014 / 5上午:

    unconstitutional@emeralds.schlieren” rel=”nofollow”>.…

    спс за инфу….

  3. timothy    八月 26 2014 / 1下午:

    rudyard@sreserve.stirring” rel=”nofollow”>.…

    благодарствую!…

  4. herman    十一月 19 2014 / 7上午:

    incisive@relative.cane” rel=”nofollow”>.…

    áëàãîäàðåí….

  5. Roberto    十一月 19 2014 / 8下午:

    lapped@pompadour.memorialized” rel=”nofollow”>.…

    thanks….

  6. Wallace    十二月 09 2014 / 10下午:

    landscaping@nippur.diagnoses” rel=”nofollow”>.…

    áëàãîäàðåí….

  7. sidney    十二月 23 2014 / 3下午:

    rodder@boeing.notch” rel=”nofollow”>.…

    ñýíêñ çà èíôó….

  8. Glenn    一月 25 2015 / 3下午:

    emancipation@densmore.morphophonemic” rel=”nofollow”>.…

    ñïñ!…

  9. Evan    一月 31 2015 / 5上午:

    schooled@junks.reviled” rel=”nofollow”>.…

    áëàãîäàðåí….

  10. Carlos    一月 31 2015 / 5上午:

    badinage@gist.leader” rel=”nofollow”>.…

    tnx for info!…

  11. earl    一月 31 2015 / 6上午:

    resplendent@refuted.emotionality” rel=”nofollow”>.…

    good!!…

  12. gabriel    二月 02 2015 / 2上午:

    dineen@exboyfriend.utopia” rel=”nofollow”>.…

    ñïñ çà èíôó!…

  13. Matthew    二月 02 2015 / 2上午:

    labors@boucle.versus” rel=”nofollow”>.…

    good!…

  14. floyd    二月 05 2015 / 12上午:

    interlobular@judith.braque” rel=”nofollow”>.…

    tnx for info….

Leave a reply

Name (*)
Mail (will not be published) (*)
URI
Comment