strategy of sorting in this problem..

This is a discussion on strategy of sorting in this problem.. within the C Programming forums, part of the General Programming Boards category; Code: here is the original question: in order to relocate a factory there where hired 10 trucks. in order to ...

  1. #1
    Banned
    Join Date
    Jul 2009
    Posts
    46

    strategy of sorting in this problem..

    Code:
    here is the original question:
    in order to relocate a factory there where hired 10 trucks.
    in order to make it safely  the cost of insurance in relation with the items in the trucks
    were calculated.
    every item  belongs to one of three categories 0 ,1 ,2 
    for  category 0 there is 0.02% of the item value  payment .
    for category 1 there is 0.07% of the item value  payment  .
    for  category there is 0.15% of the item value  payment.
    
    for every truck there is a file in which every line is an item which looks like this:
    ID{5 chars}  how_many{4 chars} comment{25 chars}   
    the file is sorted by ID in ascending order.
    
    also there is a catalog file in which each line also represents an item.
     ID{5 chars}  category{1 char 0,1,2}  price{6 chars}
    
    the file is sorted by ID in ascending order.
    
    before the ride the manager asked to create a file for each category
    in which there would be the items which were transported from this category.
    each   line in this file  represents an item
    ID{5 chars} amount{5 chars} price{6 chars} insurance_cost{XXXXX.XX 5 chars whith 2 chars precition.  }
    
    write a function called 
    
    void insure (FILE* f_van[10],FILE *f_item, char* fname[3])
      
    f_van is the truck files
    f_item is the catalog file
    fname[3] is the names of files which the manager asked to make
    
    the file needs to be sorted by ID in ascending order.
    "
    this is so complex i dont know what is the strategy here

    ??

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    The strategy for sorting here is "ascending by ID number". Fortunately or unfortunately for you, that is completely irrelevant, since the data will be given to you in ascending order by ID number, so you won't have to sort it.

  3. #3
    Banned
    Join Date
    Jul 2009
    Posts
    46
    ok,
    what two files do i compare by id?
    where do i put the match?
    in what step i do the calculation?


    can you tell me the general strategy?

  4. #4
    Registered User slingerland3g's Avatar
    Join Date
    Jan 2008
    Location
    Seattle
    Posts
    602
    Again this is a classic example of how would you do this without writing any code. The way I see it:

    1. You have 10 vans each with their own shipping docket of items by ID only and how many of each they are shipping.

    2. You will need to compare your catalog of items against each van shipment. You have the items IDs already on hand to accomplish this and now you have their catalog and pricing.

    3. From step 2 you will then need to compare the shipments of each van to that of what your manager wants you to do in order to list each item by catagory and by ascending order of item IDs. As tabstop mentioned that is pretty much done for you.

  5. #5
    Banned
    Join Date
    Jul 2009
    Posts
    46
    ok this ill try to write it down into code.
    thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Sorting problem?
    By audinue in forum C Programming
    Replies: 5
    Last Post: 01-06-2009, 01:16 PM
  2. Array Sorting problem
    By ___________ in forum C++ Programming
    Replies: 4
    Last Post: 07-22-2008, 12:17 AM
  3. What is problem about the sorting?
    By Mathsniper in forum C Programming
    Replies: 2
    Last Post: 04-17-2005, 07:00 AM
  4. Sorting text file problem...
    By John-m in forum C Programming
    Replies: 3
    Last Post: 10-01-2002, 04:51 PM
  5. Sorting array output problem
    By Unregistered in forum C Programming
    Replies: 4
    Last Post: 02-19-2002, 12:44 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21