Thread: Lotto program

  1. #1
    Registered User
    Join Date
    Jun 2013
    Posts
    2

    Lotto program

    Hello!
    I have a little problem with a lotto program. I have the source code and when i put it in the compiler it gives me some errors. The program should do something like this: take the last draw of a 6 49 lottery, break all 6 numbers in all 15 pairs, and then search each pair in the past draws to see where has hit recently. It shows how many draws elapsed since last hit. The source code is like this:

    Code:
    // Here i see the 1-15 pirs 
     
    int int0, int1, int2, int3, int4, int5, int6; 
    int pair[15][3]; 
    int foundul=0; 
    for (int0=0; int0<15; int0++) { pair[int0][0]=0; pair[int0][1]=0; pair[int0][2]=0; } 
     
    // until here i make for each draw (ik) a new matrix, with zero all the values; 
     
     
    // starting from here i make the matrix of the pairs, according to history draws... this function executes each time ik changes, for every draw, 
    //starting from ik+1 to the end... (in my case 912). Normaly this 912 must be a variable, or input from keyboard by user,
     
    for (int3=(ik+1); int3<912; int3++) 
                 for (int4=0; int4<6; int4++) 
                   for (int5=0; int5<6; int5++) 
     
            if (int4!=int5) 
             { 
             for (int1=0; int1<6; int1++) 
                     for (int2=0; int2<6; int2++) 
     
                if ((tabel[ik][int1]==tabel[int3][int4])&&(tabel[ik][int2]==tabel[int3][int5])&&(int1!=int2)) 
             { 
              int found=0; 
                for (int6=0; int6<15; int6++) 
     
                   { 
                    if ((tabel[int3][int4]==pair[int6][0])&&(tabel[int3][int5]==pair[int6][1])) found=found+1; 
                    if ((tabel[int3][int4]==pair[int6][1])&&(tabel[int3][int5]==pair[int6][0])) found=found+1; 
     
                   } 
     
               if (found==0) foundul=foundul+1; 
               if (found==0) pair[foundul-1][0]=tabel[ik][int1]; 
               if (found==0) pair[foundul-1][1]=tabel[ik][int2]; 
               if (found==0) pair[foundul-1][2]=(int3-ik); 
     
     
             } 
     
     
     
       } 
     
     
     
     
     // here i print the pairs  
     
    int int13; 
     for (int13=0; int13<15; int13++) 
     { 
     
       fprintf (fp, "\n%d %d   %d     pair no %d", pair[int13][0], pair[int13][1], pair[int13][2], int13); 
     
     } 
     
     
    // Here i finish the 1-15 pairs
    And the result should look like this:
    pool no 1
    12 44 2 pair no 0
    30 44 12 pair no 1
    30 49 24 pair no 2

    ................
    12 44 is the pair
    2 is the draws when last hit.

    Thank you for your answers !

  2. #2
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,472
    You are not making it any easier for yourself by naming your vars and loop comtrols as numbers, it is totally confusing, terrible naming convention, just use i,j,k for nested loops or call them something meaningful like int drawCount, int pairCount
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

  3. #3
    Registered User
    Join Date
    Jun 2013
    Posts
    2
    I can't do it! All i have is errors like:

    "Line 9 C:\Users\Admin\Desktop\Dev-Cpp 5.4.2 MinGW 4.7.2 Portable\loto.c [Error] expected identifier or '(' before 'for' "
    Line 18 C:\Users\Admin\Desktop\Dev-Cpp 5.4.2 MinGW 4.7.2 Portable\loto.c [Error] expected '=', ',', ';', 'asm' or '__attribute__' before '<' token

  4. #4
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    Oh, you're clearly one of those F (feeling) personality types. Just an observation. This will make it a lot more difficult to get help with your actual program. You may need to step outside your comfort zone by putting your feelings aside and just focusing on providing answers to any questions we have of you etc.
    For example: is this your entire file? (Line 9 certainly has a 'for' on it). Program code must be contained within a function.
    I would expect a main function for this code. Do you have a 'main' function for this?
    How do you come to have so much code that will not compile? A general development process is to write only a couple of lines at a time, compile that, and repeat. If it does not compile then the bug is probably in the last few lines you added or changed.
    When dealing with errors, always start from the first one it shows you. Fix that one and then hit compile again. Often times other errors will go away as they may have been aresult of the one you just fixed.

    Don't despair, you'll get there, just keep at it.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. PLEASE HELP C Language Lotto Game
    By hotshotennis in forum C Programming
    Replies: 2
    Last Post: 01-28-2012, 08:54 AM
  2. lotto program in c
    By vyshant in forum C Programming
    Replies: 7
    Last Post: 11-07-2011, 12:19 PM
  3. Lotto problem
    By Roaring_Tiger in forum C Programming
    Replies: 11
    Last Post: 03-13-2003, 10:17 PM
  4. Lotto game in C
    By fun2sas in forum C Programming
    Replies: 2
    Last Post: 03-02-2003, 07:19 PM
  5. Combinations, lotto, 6/49
    By Robert in forum C++ Programming
    Replies: 8
    Last Post: 12-06-2002, 07:27 PM