By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,750 Members | 1,221 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,750 IT Pros & Developers. It's quick & easy.

arrays

P: 6
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.
Nov 6 '06 #1
Share this Question
Share on Google+
1 Reply


P: 34
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<structType> 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.cppreference.com
Nov 6 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.