Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
* * * * * 1 votes

[C++ Homework] Need help with vectors

vecto array challenge c++

This topic has been archived. This means that you cannot reply to this topic.
4 replies to this topic

#1 jason1221

jason1221

    CC Lurker

  • New Member
  • Pip
  • 3 posts

Posted 10 April 2015 - 08:20 AM

Share with you! I code with 226lines :( , and you?

More specific description of Input, Output of the program with mario

  • INPUT: testcase_X_X.txt the file. Example: file testcase_1_1.txt

         In this testcase file consists of two components:
                (1) Line 1 to 10: (map) contains information of a map, a map such as size 10x20
                (2) Line 11: The operation goes: each sequence of operations go, separated by a space ('')
Will have the code to help you read 2 content. Content (1) recorded in the 2-dimensional array map [10] [20] and the content (2) recorded in the vector step

  • OUTPUT screen print:

                Line 1: goes through eg (1.0) (2.5) (diaphragm before recording, released the following record); each cell
separated by a space (' '). Oh what goes through two or more times, in both 2 or more times.
If the command is not still in the current coordinates
                Line 2: Total points that Mario achieved only when the next destination, if not to the destination, in -1 (no later down the line)

  • Description of requirements

                Manipulation brief description:
                LEFT_ : Scroll left 1 unit
                RIGHT : Move right 1 unit
                JUMP_ : Jumping usual spot up 2 units and falling in the initial position
                LJUMP : Jumping up to 2 units left, left 2  shares fall
                RJUMP : Jump right up 2 units to the right 2 shares fall

  • Described in more detail on the map

                Call coordinates of Mario is the 2-dimensional array corresponding to x and y, the origin is located at the bottom left map and start with 0.

                Condition: 0 ≤ x ≤ 19; 0 ≤ y ≤ 9, 19 + 1 which is the maximum length of maps, 9 + 1 is the maximum height of the map. Symbols of objects on a map:

                 '#': Representing rock wall, obstacle

                 ' ' (Blank character) represents the space (possibly moving)

                 '$' Representatives for money, only one character per box corresponding to 1 point

                 '! ': Destination

                '@': The starting point

  • Objective: Mario away from the starting point, take the first row of the previous operation, can reach the destination or not; passing on the road if the position of the coin, the coin feeding.
  • Note:

                   Each coin will be 1 point edible. Up is edible when Mario goes through the path of the coin. Only when Mario are about to target only. If the score is -1

                  The starting point is always on the ground (coordinates is (x, 0)) and end point located anywhere on the map.          

                  Money may be scattered in the street. Obstacles to block the road just as (if no further action can be overcome) or can be flipped to eat pedestal currencies or to jump to the next level.

                  During the migration process, if you encounter the edge of the map editor that is seen as an obstacle.

In the process, if it does not pass through the target and then go forward again, ending the program and the number of points earned is the amount eaten.

  • More specific description of the operation

       Normally, if the current position is (x, y) is:
               - Perform LEFT_, the new location is (x-1, y) and the cells go through the (x-1, y) if 1 without any other conditions (**) (see below)
               - Doing RIGHT, new position is (x + 1, y) and the cells go through the (x + 1, y) if as there are no other conditions 1 (**) (see below)
               - Perform JUMP_, the new location is (x, y) and the cells go through the (x, y + 1), (x, y + 2) without any other condition 1 (**) (see below)
               - Perform LJUMP, for the new position (x-2, y), and the cells go through the (x, y + 1), (X, y + 2) (x-1, y + 2) (x-2, y + 2) (x-2, y + 1), (x-2, y) without any just one thing other events (**) (see below)
               - Perform RJUMP, for the new position is (x + 2, y), and the cells go through the (x, y + 1),(X, y + 2) (x + 1, y + 2) (x + 2, y + 2) (x + 2, y + 1), (x + 2, y) without any just one thing other events (**) (see below)

  • (**) A number of other conditions, otherwise self-similar reasoning, if the current position (x, y):
  1.  Perform JUMP_ but on obstructions (x, y + 1), it can not be done. But if obstructions from one box at the top (x, y + 2) is still performed, but only one cell was jumping up and falling back to the position before jumping.
  2. Perform LEFT_ but left with no obstructions shall be done
  3. Perform RIGHT but right obstructions are not done
  4.  Perform LEFT_ but not the left is about to fall down to touch the ground or the nearest obstacle, namely the new coordinates are (x-1, yn), where N is the height from the point of falling to land or the nearest obstacle.
  5.  Same as above with manipulation RIGHT
  6.  Perform instant LJUMP if left obstruction elevation ≥ 3 (compared to the positionpresent) is not done and seen as JUMP_ normal operation,lower if it can perform the operation. Similar to manipulate RJUMP.
  7.  For LJUMP and RJUMP, similar to JUMP, if there are obstructions immediately above,can not be done; if there are obstructions from one box at the top is still done but only 1 box jump up and to the left or right by one cell only and falls (without obstructions).
  8.  During the migration process, if you encounter an obstacle, it will fall right at close objects prevent possible.
  9.  Similarly LEFT_ and RIGHT, LJUMP and RJUMP if the point falls space will continue to drop until the ground or the nearest obstacle.

 

 

Attached Files



#2 jason1221

jason1221

    CC Lurker

  • New Member
  • Pip
  • 3 posts

Posted 10 April 2015 - 08:41 AM

First, you download file myprog.cpp to view code and complete rest of code!



#3 dargueta

dargueta

    I chown trolls.

  • Moderator
  • 4854 posts

Posted 11 April 2015 - 06:01 PM

This looks like homework. At CodeCall we gladly help with homework, but we won't do it for you. What do you need help with specifically?


sudo rm -rf / && echo $'Sanitize your inputs!'


#4 jason1221

jason1221

    CC Lurker

  • New Member
  • Pip
  • 3 posts

Posted 11 April 2015 - 09:54 PM

This looks like homework. At CodeCall we gladly help with homework, but we won't do it for you. What do you need help with specifically?

Yes, it is precisely the exercise, ask my teachers have less than 200 lines of code. I tried but could only get 226 lines.



#5 dargueta

dargueta

    I chown trolls.

  • Moderator
  • 4854 posts

Posted 11 April 2015 - 10:02 PM

1) Just because you have more lines doesn't mean your implementation is wrong.

2) myprog.cpp isn't 226 lines. I don't see your work anywhere.


sudo rm -rf / && echo $'Sanitize your inputs!'





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download