arrays

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jetboy555
    New Member
    • Nov 2006
    • 6

    arrays

    Using C++ language I need to write a program that first separates the data into arrays for year, Winner, Winner's score, Runner-up, Runner-ups score. I’m having trouble putting all my data into arrays. later I will have to search through the data using the searches from input 2. Where the first term means what to search by, then the value of that search, and if followed by 1 the output the winner, if 2 output the loser.


    Sample Inputs:

    Women's Track Fciac Champions: 8
    ------------------------------------------------------
    1982 Ridgefield high 76 Danbury 62
    1983 Ridgefield High 69 Staples High 67
    1984 Staples Highl 72 Danbury 61
    1985 danbury 70 Trumbull 65
    1986 Trumbull 97 Danbury 81
    1987 Trumbull 67 Louisiana Tech 44
    1988 Danbury 56 Trumbull 54
    1989 Trumbull 76 Danbury 60

    Input 2:

    year 1988 2
    year 1990 1
    year 1986 1
    titles Danbury
    titles Trumbull


    I’m having a very hard time on this program, any help will be appreciated.
  • dariophoenix
    New Member
    • Oct 2006
    • 34

    #2
    Originally posted by Jetboy555
    Using C++ language I need to write a program that first separates the data into arrays for year, Winner, Winner's score, Runner-up, Runner-ups score. I’m having trouble putting all my data into arrays. later I will have to search through the data using the searches from input 2. Where the first term means what to search by, then the value of that search, and if followed by 1 the output the winner, if 2 output the loser.


    Sample Inputs:

    Women's Track Fciac Champions: 8
    ------------------------------------------------------
    1982 Ridgefield high 76 Danbury 62
    1983 Ridgefield High 69 Staples High 67
    1984 Staples Highl 72 Danbury 61
    1985 danbury 70 Trumbull 65
    1986 Trumbull 97 Danbury 81
    1987 Trumbull 67 Louisiana Tech 44
    1988 Danbury 56 Trumbull 54
    1989 Trumbull 76 Danbury 60

    Input 2:

    year 1988 2
    year 1990 1
    year 1986 1
    titles Danbury
    titles Trumbull


    I’m having a very hard time on this program, any help will be appreciated.
    To begin with, you should define a struct with the fields you need (year, winner, score, etc. with the typed you think appropiate). Then, define a vector<structTy pe> and push_back the records received in input 1. When you need to search, to make it simple, ask for an iterator for the vector and search sequentially comparing the corresponding field.
    This site is great:

    www.cppreferenc e.com

    Comment

    Working...