Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ GimmeCode Homework
A thief Muthhooswamy planned to escape from Tihar jail. Muthhooswamy is basically a monkey man and he is able to jump across the wall. He practiced to cross a wall and he is able to jump 'X' meters, but because of slippery wall he fall 'Y' meters after each jump. To escape from jail he has to cross 'N' number of walls where height of each wall is given in an array. Write a program to find out the total number of jumps he will make to escape from the jail.
 
#include <iostream>
#include <string.h>
#include<conio.h>
 

void GetJumpCount(int climbUp,int climbDown,int noOfWalls,int wallHeights[])
{
    int clu,cld,now,n,count;
    count=0;
    clu=climbUp;
    cld=climbDown;
    now=noOfWalls;
    //wh[]=wallHeights[];
    n=lenghtof.wallHeights[];
    for(int i=0;i<n;i++)
    {
    int ht=0,temp=0;
    ht=wallHeights[i];
    while(ht<(temp=clu-cld))
    {
    if(temp>ht)
        {
        count++;
        break;
        }
    else
        count++;
    }
    }
    cout<<count;
 
}
 
void main()
{
    clrscr();
    GetJumpCount(10,1,1{10});
    getch();
}
Posted 22-Sep-11 5:30am
Edited 23-Sep-11 4:51am
v3
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

No
 
We don't do YOUR homework. Well get your wallet out and then maybe we do.
  Permalink  
Comments
Mehdi Gholam at 22-Sep-11 11:09am
   
My 5!
Simon Bang Terkildsen at 23-Sep-11 4:58am
   
Thank you, Mehdi :)
vdkolekar at 23-Sep-11 8:07am
   
Hello Bang Bang!!!!!!!!
If you cant answer or If you dont want to reply your answer then dont post like this S**T........like you are begging here...for money...(bhikari sala)
Simon Bang Terkildsen at 23-Sep-11 8:30am
   
You ask us to give you code like many before you, we do not do that, move on unless you want to pay someone for doing your work. Note I'm not asking/begging for money, I would never do work for you.
 
The lack of answers with code to this question seems to indicate that the other very helpfull poeple here on CP agrees with me.
_Zorro_ at 23-Sep-11 9:21am
   
Yep, I'm with you. He seems to be too arrogant to understand anyway..
Marcus Kramer at 27-Sep-11 10:24am
   
If you can't do your own homework, then you maybe should not be a developer. The whole point to being a good developer is being a good problem solver. That is Simon's point here.
SAKryukov at 6-Oct-11 11:53am
   
Great point, Marcus (how could I possibly up-vote it? :-)
Simon gets my 5 here.
--SA
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

vdkolekar wrote:
A thief Muthhooswamy planned to escape from Tihar jail.
vdkolekar wrote:
Write a program to find out the total number of jumps he will make to escape from the jail.

 
We don't support criminality.




Smile | :)

  Permalink  
Comments
vdkolekar at 23-Sep-11 9:10am
   
Sir you are older than me thats why I dont want to put finger on you for FUN..
if you have some clue then post it here thats my request to you .......
otherwise leave it.......ya??????
Am I right?
_Zorro_ at 23-Sep-11 9:17am
   
No you're not... you're just too arrogant to see it.
vdkolekar at 23-Sep-11 9:24am
   
hmmmmmmmmmm..............
@Z0rr0:
its not like that I just asked question and people make it fun....
then what can you do?
I just response them in polite way.....
_Zorro_ at 23-Sep-11 9:35am
   
No you're not polite, I was reading some other questions you ask here and I see this pattern: 'Give me', 'I request this', 'I need code for'.
 
If everybody tells you the same thing maybe it's because they're right don't you think?
 
You won't find much help here to do your homework, and don't try to tell us this is not homework, come on, do you really think we're THAT stupid?
 
What can I do? Point my finger at your attitude, that's what I can do.
 
Interesting link I found here btw... http://www.techgig.com/codingcontest_detail.php?season_id=3&type=entry
vdkolekar at 23-Sep-11 10:05am
   
hey thanks for link man........
CPallini at 23-Sep-11 9:18am
   
Well, I'm not going to take advantage of a poor, inexperienced child.
:-D
vdkolekar at 23-Sep-11 9:26am
   
Well
Yes I am fresher and inexperienced.......
thnx.....
SAKryukov at 6-Oct-11 11:59am
   
"leave it"..? Why do even think that everyone should serve your needs? You asked a question to be answered by volunteers. And volunteers will help to anyone who they think is good enough to get or deserve help. Just take what you got.
How can you be so rude? Nobody did anything bad to you. As to receiving anything good... you cannot expect luck everywhere, can you?
--SA
pankaj sammal at 27-Sep-11 10:01am
   
Its a contest question, cheating in a contest.... :P
SAKryukov at 6-Oct-11 12:01pm
   
Contest? Really? Good point. Bad thing. Cheating is not just cheating; in this case it's an attempt to get benefits at the expense of honest and more deserving people.
--SA
SAKryukov at 6-Oct-11 12:03pm
   
You got my 5 for the fresh look at the question. :-)
It caused me to look at that jail. See: http://en.wikipedia.org/wiki/Tihar_Prisons, http://www.delhi.gov.in/wps/wcm/connect/Lib_CentralJail/central+jail/home. It looks like a legitimate government jail.
--SA
Simon Bang Terkildsen at 6-Oct-11 12:30pm
   
Hmm, who calls the authorities? :P
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 6

Dude this is a contest of an ongoing contest, if you cant do it for yourself, why the hell do you even bother to participate.... :P
  Permalink  
v2
Comments
vdkolekar at 28-Sep-11 5:38am
   
I asked question becoz I heard this question first from my friend .
I didnt participated ????
Actully I want hint to solve such scenario ...
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Read what's on the 'Ask a Question' page, especially items 7:
 
7. If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
 
The point of homework is making you learn something. If we do it for, we are doing you a disservice.
 
What we can do is either of the following:
 
- offer a general explanation to any specific programming topic you failed to understand
- find out what's wrong if your code doesn't work as expected, or doesn't compile (note: this does require code written by you!)
- we might also point you to an article with further information, or a specific function or library you could use; but for homework assignments I'd assume you were given all the information (and functions) you need
  Permalink  
Comments
vdkolekar at 23-Sep-11 8:12am
   
To Stefan sir
Its not assignment I came across this question from my friend asked me but I m very much weak in C++ or Programming that't why I asked here as just to get proper code or algorithm. I had completed some part of code but not working properly
1 more thing about this Web Site
coz code project is very much helpfull to me when I m doing my final year project. So I simply ask this Question
thanks for let me know about rule....
Stefan_Lang at 23-Sep-11 9:35am
   
If you already have some code you're welcome to post it and explain the problem you have with it (e. g. crashes in function xy(), or function result is wrong, whatever). We can then look into it and help you find the mistake or explain why the *specific* way you tried to solve it wouldn't work.
 
This would be much better because
a) we would only need to focus on the bits you have trouble with, instead of having to explain everything
b) you won't get bored by lots of information that you already do know
c) instead of copying a solution that you don't understand, and having to rely on help the next time you need that knowledge, you can now do it by yourself.
d) The guidelines on the 'Ask a Question' page also says the following:
Be specific! Don't ask "I need to write a booking application". Specify exactly what it is you need help with.
vdkolekar at 23-Sep-11 9:45am
   
Thank you very much sir........
 
#include
#include
#include
 

void GetJumpCount(int climbUp,int climbDown,int noOfWalls,int wallHeights[])
{
//Write code here
int clu,cld,now,n,count;
count=0;
clu=climbUp;
cld=climbDown;
now=noOfWalls;
//wh[]=wallHeights[];
n=lenghtof.wallHeights[];
for(int i=0;iht)
{
count++;
break;
}
else
count++;
}
}
cout<<count;

}
 
void main()
{
clrscr();
GetJumpCount(10,1,1{10});
getch();
}
vdkolekar at 23-Sep-11 9:47am
   
this is link where my friend get this question....
 
http://www.techgig.com/codingcontest_detail.php?season_id=3&type=entry
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

    n=lenghtof.wallHeights[];
This is not valid C syntax. Not even close. What you probably meant to do is determine the number of elements of that array. Sorry, there is no C or C++ function for that. However, you do not need to determine that number since you already passed it to the function!
 
    GetJumpCount(10,1,1{10});
You missed a comma here (before the list). Apart from that I'm not sure you can even pass an integer list as a parameter like that. If it doesn't compile, create an array variable instead, like this:
    int myarray[] = {10};
    GetJumpCount(10,1,1,myarray);
 
Since this is a contest I will only point out two simple mistakes in your algorithm:
1. the loop condition of your while loop is wrong (actually here are at least two mistakes, depending on how you resolve mistake 2 below)
2. None of the variables you check in your while loop ever get changed. The only variable that changes is count. Your prisoner is going to starve while trying to jump out of that loop Wink | ;)
 
The rest of the code is not going to win any style contest (nor this one), but if you fix all of the above, it might at least work. When it does, revisit your algorithm, it's very inefficient. Also you are not properly testing for corner cases and validity of the input.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 7

Please see my recent answer: Write c# code for this program.[^].
 
Could you please explain us how come two people can ask questions on exact same problem? (Please see my comments to Richard's comment.)
 
Thank you,
—SA
  Permalink  
Comments
Simon Bang Terkildsen at 6-Oct-11 7:54am
   
I don't think he can or will :)
SAKryukov at 6-Oct-11 11:44am
   
I don't know. Nearly every time I respond to really inappropriate or poor question in a way I do it here or just express any strong opinion (but I often have a strong opinion), someone with pretty high rating comes to down-vote it and give -16 points. Not that I ever cared about it, but it just irritates...
 
Thank you, Simon.
--SA
Simon Bang Terkildsen at 6-Oct-11 12:11pm
   
Yeah well I suppose some of the CPians who doesn't spend much time in the Q6A might see it as harsh, but in the 2 months I've spend here I would say you're in your right to went now and then.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

Enter   number of walls : N
Enter jump height : X
Enter jump slip : Y
totaljumps=0
Loop through i(0 to N-1)
     Enter each wall height wh[i]
     heightachieved=0
     while (heightachieved<wh[i])         
          totaljumps+=1
          heightachieved+=X     (is he over yet? if so - brake outta loop)
          heightachieved-=Y
     endwhile
     printout totaljumps
end loop
I assume you know how to code this and/or how to got hrough the vector etc ...
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 8

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
 
namespace WindowsFormsApplication1
{
    public partial class Form3 : Form
    {
        public Form3()
        {
            InitializeComponent();
        }
 
        private void button1_Click(object sender, EventArgs e)
        {
            int h = Convert.ToInt32(textBox1.Text);
 
            int n = Convert.ToInt32(textBox2.Text);
 
            int x = Convert.ToInt32(textBox3.Text);
            int y = Convert.ToInt32(textBox4.Text);
            string str;
            int g = 0;
            for (int i = 1; i <= n; i++)
            {
                if (x == h || x > h)
                {
                    str = "no. of jump = " + n;
                    label5.Text = str;
                }
                else
                {
 
                    g += (h / (x - y));
                    str = "no. of jump = " + g;
                    label5.Text = str;
                }
            }
        }
    }
}
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web03 | 2.8.1411022.1 | Last Updated 23 Dec 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100