I got a problem...A huge one..

Pages: 123
closed account (D80DSL3A)
OK. I followed the link supplied by hamsterman above to get the answer to the question I asked you. (BTW congrats hamsterman on reaching 1,000 posts).

This is what I needed in order to help you: p.get_x()

I didn't see where they tell exactly what data type is being stored but this Point my_point( -5.25, 2.75 ); suggests that the value is either a float or a double.
Now the lengths of the sides of the triangle can be found! The sqrt() is needed so do #include<cmath> for this.
1
2
3
4
5
6
7
8
// find length of side a using p1 and p2
double a = sqrt( ( p2.get_x()-p1.get_x() )*( p2.get_x()-p1.get_x() ) + ( p2.get_y()-p1.get_y() )*( p2.get_y()-p1.get_y() ) );

// find length of side b
double b = // as above using p2 and p3 - simply substitute p3 for p1

// find length of side c
double c = // as above using p1 and p3 


Next, determine which side is the shortest one. The smallest angle is opposite this side. You can find the minimum cosine (=cosMin) while doing this.
1
2
3
4
5
6
7
8
9
10
double cosMin = 0.0;// so it's initialized
if( a<b && a<c )// then a is the shortest side			
	cosMin = ( b*b + c*c - a*a )/(2.0*b*c);// from law of cosines
else
{
	if( b<a && b<c )// b is shortest					
		cosMin = ( a*a + c*c -b*b )/(2.0*a*c);
	else// c is shortest			
		cosMin = ( a*a + b*b -c*c )/(2.0*a*b);		
}


Done!

I hope there are no syntactical errors above. I couldn't test it because I don't have that library.

I'm expecting to get hit for supplying a full solution, but in this case the # of threads opened for this problem and the desperation expressed has led me to worry that something very bad may happen if alexbg doesn't get this one. I hope I'm wrong about that.
deleted
Last edited on
@alexbg

ok and how to set the program to take the smallest angle everytime?


Use if statements.
1
2
if(angle1 < angle2)
  // then angle1 is smaller than angle2 


double angle = /*insert math to calculate the angle here*/; u mean <cmath>?


I mean put in some mathematical calculations that calculate the angle. <cmath> is a header.


@fun2code:
So now we're doing homework assignments for people?

He's not going to learn anything if you dish out solutions.

Yeah yeah I know it's last minute and if he doesn't turn it in he'll get in "big big trouble", but maybe getting in "big big trouble" is a kick in the butt he needs.

From the questions he's asking it sounds like he hasn't been paying any attention in class -- probably because he's been getting other people to do his homework for him. Doing even more homework for him is just going to make him fall further behind.
Last edited on
closed account (D80DSL3A)
Yes - you still need to complete 2 lines:
1
2
double b = // as above using p2 and p3 - simply substitute p3 for p1
double c = // as above using p1 and p3  

And TEST IT THOROUGHLY before submitting it!!!
Also, look into whether the Line object has a length method. If it does then use:
double a = L1.length();// and for L2, L3
instead of:
 
double a = sqrt( ( p2.get_x()-p1.get_x() )*( p2.get_x()-p1.get_x() ) + ( p2.get_y()-p1.get_y() )*( p2.get_y()-p1.get_y() ) );

EDIT: I didn't notice that a,b,c are already in use for the lines. Change one set of variable names.
In my IDE if I type the name of an object and hit '.' then a list of all available methods appears. See if length is on this list.

@Disch - I gave my reason for breaking the rule in this particular case.
I believe you won't find any other cases where I have done this.
Last edited on
Of courese Ill try before submitting.What does length method mean?How can i findout if the object has length method?

deleted
Last edited on
fun2code wrote:
but in this case the # of threads opened for this problem and the desperation expressed has led me to worry that something very bad may happen if alexbg doesn't get this one. I hope I'm wrong about that.


(I actually missed this part until you referenced it in your more recent reply. My apologies)

Anyway, this just reinforces bad behavior. You're basically rewarding him for triple-posting and begging. That's not the kind of thing we should encourage.

If something really bad happens to him as a result of him not turning in his assignment, maybe that's for the best. Like I mentioned before, maybe he needs a swift kick in the ass to get him in gear. Your solution doesn't do that, it just let's him coast even further on the backs of others.

What are you going to do next week when he has another assignment that he doesn't know how to do... and the consequeces of not turning it in are EVEN MORE dire?
closed account (D80DSL3A)
You left a / in place on one line:
double c = /sqrt( ( ...
Remove that /.
I edited my post above re: the other errors.

EDIT: @Disch. I was worried about suicide, not about flunking a course.
Next week is on someone else. I won't do it again.
I agree completely with your reasons for not doing others homework problems for them.
Last edited on
@Disch. I was worried about suicide, not about flunking a course.


I think that's a little extreme =P
deleted
Last edited on
@alexbg

I don't have a problem with you being a beginner. I'm happy to help beginners. My problem is that you came here looking for a handout.

Now you have your solution, sure, but you didn't learn anything from the assignment. Now the class is moving ahead having learned how to do this task, and you skated by without learning it -- so you're falling behind everyone else. Now you're just going to have a harder time because you need to catch up to everyone else.


That's beside the fact that I simply don't believe you. This in particular sounds incredibly lame:

i got two professors , who were not in the town this week, so there were no one to explain to us what are those programs.


You expect me to believe that you got assigned something that they did not explain how to do in class (or in your reading material) -- then disappeared so you couldn't contact them for help? I've never heard of any professor doing this.

I find one of the below scenarios much more likely:

1) You're taking a class you're ill prepared for (like a 2nd level course when you never took the 1st level)

2) You didn't do any studying and waiting until the last minute to do this assignment, then realized it was harder than you thought and paniked.

3) The material was covered in class, or in your books, and you should have learned how to do it, but you didn't pay attention and/or couldn't follow it.



Basically -- you don't have my sympathy. If you're struggling with a coarse, there are options. Talk to your professor, form study groups with your classmates, get a tutor, etc, etc.

There are many things you could do. Getting answers to homework problems off the internet is not one of them.
Disch

why you people constantly break down.
Would you, or you do not help either.

this is a forum.
What is the purpose of this forum?
to answer questions from people who could not cope with.
not judging them.

Please
constantly judging people!!!

Do you lie to say or not say?
purpose:
only to help;



Disch's insight is overwhelmingly helpful. I suggest reading it again and taking it to heart.
deleted
Last edited on
Oh god...another "programmer" that doesn't know how to program. *facepalm*
I dont pretend to be a programmer I am a beginner, i sad it may be 1000 times already.I just needed help.
Firedraco, i can say about u " Oh god...another rooster"
I dont understand whats wrong????Isnt it the point of the forums??-to discus and solve problems together???Why r u here if u dont want to solve problems and discus programs??Isnt it the place where beginners and masters exchange experience?
Should I be a master to post here?I had a problem, i needed a solution, i needed some advices, i needed to discus it with people who know more than me.And its not so hard to notice that most of the topics are about problems in programing.
Its very bad that in every forum there are people who are very big in the virtual space but no one in the real life, and they try to be sooo smart here, because everybody avoid them everywhere else...U r pathetic .........
Try to work together, its easier.Those who r here just to post tales like "Oh god...another "programmer" that doesn't know how to program. *facepalm*"- u r useless.Useful in that topic were fun2code and the other guys, who helped me, not u.......
You're missing the point entirely, alexbg.

You're right about one thing: The forum is for helping people with C++ problems.

The problem is you weren't helped with your C++ problem. You were handed a homework solution. That doesn't help you solve a C++ problem in any way shape or form.

I want to see you learn C++. I want to help you learn C++. But that's not what you were looking for. You were looking for a handout. That's not what we do here.


And its not so hard to notice that most of the topics are about problems in programing.


It's also not so hard to notice that most of the topics are about helping the person write the code on their own -- not about giving the code in full.

Its very bad that in every forum there are people who are very big in the virtual space but no one in the real life, and they try to be sooo smart here, because everybody avoid them everywhere else...U r pathetic


I'm glad you know so much about firedraco and me.

Actually, this might surprise you, but we know a few things about you too:

- You're a slacker.
- You don't care about learning C++, you only care about passing the course.
- You're a spoiled brat. You beg, whine, and throw tantrums until you get what you want.
- You're incapable of doing things on your own.
- You have poor grammar and spelling.
- You're ugly
Disch! That's not how we treat people who don't want to learn C++. We link to any applicable articles like "How To Ask", etc. Don't lower yourself to the level of someone who calls others pathetic.

Similarly, alexbg, don't call others pathetic if you need help from them. Disch made a good point; those of us who have been here a while generally don't give homework problem solutions here, and for a good reason.

-Albatross
Last edited on
I'm glad you know so much about firedraco and me.


firedraco and I :P

Disch! That's not how we treat people who don't want to learn C++


You could probably find enough examples on the internet to make an argument that it is how.

- You don't care about learning C++, you only care about passing the course.


Good point. If someone wants to truly learn about a subject they will probably do extensive research before resorting to asking questions.

I'm not sure why I felt it was necessary to come into this thread, but here I am :)

Correction: That is not how we should treat people who don't want to learn C++.

-Albatross
Pages: 123