+ Reply to Thread
Results 1 to 4 of 4

Thread: ROBOT ASSEMBLY-- C language

  1. #1
    Newbie hummer350 is an unknown quantity at this point
    Join Date
    Jul 2008
    Posts
    1

    ROBOT ASSEMBLY-- C language

    An example might be as follows. We want to build a part number, 4789. Part number 4789 is composed of 3 items of part number 1567, part number 4567 (which is a sub assembly) and part number 6791. Part number 4567 requires the assembly of two items of part number 7864 and one item of 7814. In order to build part number 4789 we could fetch part numbers 1567, 6791, 7864, 7814 then assemble part numbers 7864 and 7814 into 4567 then assemble 1567, 6791, and 4567 into 4789.

    We have been asked to write the control software for a simple robot that will build assemblies. Fortunately for us, it is a very simple robot...it can only perform 4 operations:

    * OPERATOR CODE 1 : fetch n items of a specific part number and put them individually on a stack.
    * OPERATOR CODE 2 : assemble a part by retrieving (popping) the last n items off the stack and then placing the newly assembled item on the stack.
    * OPERATOR CODE 3 : perform a final assembly of all items and subassemblies in the stack.



    Detailed Description.
    Our robot will receive simplified input from a user using scanf() (i.e. scanf("%d%d%d",&var1,&var2,&var2) with no prompting and only perform the necessary stack operations with the input data with no extra messages except for the final result. We will only support 3 of the opcodes. Opcode 1 fetches n items of a partnumber and places them individually on a stack. Opcode 2 pops the last n items on the stack to create a new part and pushes the new part back on the stack. Opcode 3 simply prints out the part number of the final product and then every item in the stack separated by 1 space. Our robot can only handle 12 items in the stack at a time and if at any time this is exceeded, a single string "FAILURE" is printed using printf() and the program exits. Make certain you exit gracefully (don't just call exit() if you detect a stack overflow in a sub-function). A non-trivial penalty is assigned for any use of an exit() in your program.

    Special Note: All that a subassembly does is pop a certain number of items of the stack assemble them into another partnumber
    then push the new part number onto the stack in place of all the items that were popped. There is no need to validate that the items popped actually relate to the part number. Your primary concerns are that the subassembly doesn't cause a stack underflow.


    INPUT:

    Each instruction will be entered by a user in the format below with each item on an input line separated by a single space. In the special case of the final assembly a NOITEMS of -1 will be used, since all items in the stack must be assembled.

    <OPCODE> <PARTNUMBER> <NOITEMS>

    An example of the input to create part number 4789 is shown below.
    INPUT :

    1 1567 3
    1 7864 2
    1 7814 1
    2 4567 3
    1 6791 1
    3 4789 -1

    OUTPUT:

    In all cases, output will be a single line of text with no newlines or tabs. When the robot can successfully assemble the part, you will print out the final part number then the part number of each item on the stack starting from the top of the stack. An example for the input above is shown below.

    4789 6791 4567 1567 1567 1567

    Please note that there are 3 instances of 1567 and there are no instances or either 7864 or 7814. There are no instances of 7864 or 7814 because those were used to create sub-assembly 4567.

  2. #2
    Learning Programmer bvaessen is on a distinguished road
    Join Date
    Jul 2008
    Location
    Limburg
    Posts
    30

    Re: ROBOT ASSEMBLY-- C language

    And the questions about this is ... ? Are you looking for professional manpower? In that case you could have a look at Launch-IT :: Home

  3. #3
    Super Moderator WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther's Avatar
    Join Date
    Jul 2006
    Age
    36
    Posts
    11,680
    Blog Entries
    57

    Re: ROBOT ASSEMBLY-- C language

    My hunch is this is a homework assignment. No real description of a problem starts with "An example of this is..."
    CodeCall Blog | CodeCall Wiki | Shareware
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  4. #4
    Code Warrior dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta's Avatar
    Join Date
    Oct 2007
    Age
    19
    Posts
    2,843
    Blog Entries
    8

    Re: ROBOT ASSEMBLY-- C language

    Well, encapsulate each of the parts in a class, use the std namespace so you can get stacks and stuff. At least try. Pseudocode? Something?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Free Assembly Tutorials
    By Jordan in forum General Programming
    Replies: 41
    Last Post: 11-09-2009, 08:24 PM
  2. C++ to assembly conversion
    By Kaishain in forum C and C++
    Replies: 5
    Last Post: 07-17-2009, 11:16 PM
  3. new C-like programming language
    By kenna in forum Software Development Tools
    Replies: 14
    Last Post: 09-03-2008, 02:34 PM
  4. Best scripting language to incorporate into game
    By torleif in forum C and C++
    Replies: 0
    Last Post: 06-20-2008, 03:04 AM
  5. Language... Games.
    By trivia in forum General Programming
    Replies: 11
    Last Post: 10-27-2007, 09:48 AM

Bookmarks

Bookmarks

     
        Algorithms and Data Structures

        Java tutorials

        Algorithms Forum

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts