Forum     

Go Back   Digit Technology Discussion Forum > Software > Programming
Register FAQ Calendar Mark Forums Read

Programming The destination for developers - C, C++, Java, Python and the lot


Closed Thread
 
LinkBack Thread Tools Display Modes
Old 02-11-2009, 07:03 PM   #1 (permalink)
Simply a DIGITian
 
krishnandu.sarkar's Avatar
 
Join Date: Nov 2007
Location: Kolkata
Posts: 2,942
Unhappy Need Help In a C Program...Plz Help Me Out


Define a structure called cricket that will describe the following information:
1. Player_Name
2. Team_Name
3. Batting_Avg

Using cricket declare an array of 50 elements and write a program to read the information about all the 50 players and print a team wise list containing names of players with their batting avg.

Guys I'm stuckd with this team wise printing part.

Say a user entered players of team in this manner
india-india-australia-pakistan-india-pakistan-australia

So I need to print 3 India players thn 2 australia players and than 2 Pak players.

Now a diff user can enter different team name and in different manner

So how shud i sort the array according to team name or simply print it team wise.

Plz help....
__________________
  • Read The Forum RULES First.
  • Before PM'ing Or Asking Any Questions To Any Mod Read The FAQ's
  • Before Starting A New Thread Read The STICKY THREADS First
  • Before Participating In Bazaar Section Read The BAZAAR RULES
krishnandu.sarkar is offline  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 04-11-2009, 12:55 PM   #2 (permalink)
Always Fresh!
 
shri's Avatar
 
Join Date: May 2004
Location: Mangalore
Posts: 192
Default Re: Need Help In a C Program...Plz Help Me Out

Sorting is one option. But involves a little bit of work.

Or you can do this:
Read the team name of the first structure.
Compare this name with the rest of the structures
Print player name when the team names are matching
__________________
BE YOURSELF :)
http://everythingoutthere.co.cc
shri is offline  
Old 04-11-2009, 06:31 PM   #3 (permalink)
Simply a DIGITian
 
krishnandu.sarkar's Avatar
 
Join Date: Nov 2007
Location: Kolkata
Posts: 2,942
Default Re: Need Help In a C Program...Plz Help Me Out

Quote:
Originally Posted by shri View Post
Or you can do this:
Read the team name of the first structure.
Compare this name with the rest of the structures
Print player name when the team names are matching
Well I tried this.......

But say......I insert the team name in the array in this sequence

Ind-Aus-Pak-Ind-Aus-Pak-Ind-Aus-Pak

Now all Ind gets printed....

Now I'm stuck how to get the Aus from that array and make sure that Ind doesnt gets printed again......
__________________
  • Read The Forum RULES First.
  • Before PM'ing Or Asking Any Questions To Any Mod Read The FAQ's
  • Before Starting A New Thread Read The STICKY THREADS First
  • Before Participating In Bazaar Section Read The BAZAAR RULES
krishnandu.sarkar is offline  
Old 05-11-2009, 09:47 AM   #4 (permalink)
Always Fresh!
 
shri's Avatar
 
Join Date: May 2004
Location: Mangalore
Posts: 192
Default Re: Need Help In a C Program...Plz Help Me Out

This is a crude solution.

Maintain a flag array say is_printed[MAX_SIZE].
Initially all entries in the array are 0.
When a particular team player name is printed the corresponding index in the is_printed[] array is made 1.

Ex: ind-aus-pak-ind-aus-aus-pak = 7 players
Before printing any : is_printed[] = {0,0,0,0,0,0,0}
After printing ind players: is_printed[] = {1,0,0,1,0,0,0}

Now, during the second iteration, when you need to print the aus players, do a check on the is_printed array and skip the structure for the index having a 1 in the is_printed array. i.e you'll skip the 0th nad the 3rd structure.
__________________
BE YOURSELF :)
http://everythingoutthere.co.cc
shri is offline  
Closed Thread

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Post your C/C++ Programs Here Gigacore Programming 746 27-11-2011 05:20 PM
Installing software from source in Linux topgear Tutorials 5 11-03-2008 01:52 PM
<<<< Help Plz Help >>> ::cyborg:: QnA (read only) 2 14-10-2007 07:37 PM
CHALLENGING C PROGRAM...-atleast for me vinit suri QnA (read only) 11 11-10-2007 09:46 PM
Help me plz plz plz n plz The Incredible QnA (read only) 4 24-05-2005 08:25 PM

 
Latest Threads
- by Charan
- by Charan
- by clmlbx

Advertisement




All times are GMT +5.5. The time now is 03:12 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2