Thread: comparing arrays

  1. #1
    Registered User
    Join Date
    Jan 2004
    Posts
    2

    comparing arrays

    Here is the requirements for this program:

    Your program will ask the user for an input file with the data for the ticket purchases. Then your program will ask the user for the winning combination of numbers. you must pick 6 distinct numbers from the set {1,2,3,...,52,53}.) The user MUST enter these numbers in ascending order. Once these have been entered, your program should print out the names of all the winners, along with how much money they have won. Use an enumerated type for the four possible winning values.

    example of the output:
    Code:
    Enter the name of the file with the ticket data.
    input.txt
    Enter the winning Lottery numbers
    17 19 33 34 46 47
    Mark Llewellyn matched 3 numbers and won $10.
    Brian Young matched 6 numbers and won $1000000.
    Max Siu matched 5 numbers and won $10000.
    Murat Balci matched 4 numbers and won $100.
    problem:
    I already have the two arrays but I'm not sure how to compare them, count how many numbers each individual person got correct and then printing out their name, how many they got right, and how much they recieve. any help is appreciated.

  2. #2
    Senor Member nomi's Avatar
    Join Date
    Jan 2004
    Posts
    129
    make a function to compare two numbers in array1 and array2, return 1 if equal, 0 if not....

    Code:
    if (array1[i] == array2[i]){
       return 1;
    }
    else{
       return 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Comparing Arrays question
    By taugust7 in forum C++ Programming
    Replies: 36
    Last Post: 04-14-2009, 12:29 PM
  2. Comparing elements of character pointer arrays
    By axe in forum C Programming
    Replies: 2
    Last Post: 11-14-2007, 12:20 AM
  3. Comparing 2 elements from 2 different arrays
    By Dan17 in forum C Programming
    Replies: 3
    Last Post: 11-15-2006, 02:43 PM
  4. Comparing Arrays
    By Raison in forum C++ Programming
    Replies: 10
    Last Post: 04-20-2004, 02:21 PM
  5. Comparing Character Arrays
    By LostNotFound in forum C++ Programming
    Replies: 2
    Last Post: 02-23-2003, 12:42 PM