
Apologies for the shouting but this is important.
When answering a question please:
 Read the question carefully
 Understand that English isn't everyone's first language so be lenient of bad spelling and grammar
 If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome
 If the question is inappropriate then click the 'vote to remove message' button
Insults, slapdowns and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid.
cheers,
Chris Maunder
The Code Project Cofounder
Microsoft C++ MVP





For those new to message boards please try to follow a few simple rules when posting your question. Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
 Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
 Keep the subject line brief, but descriptive. eg "File Serialization problem"
 Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
 Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
 Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
 If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode "<" (and other HTML) characters when pasting" checkbox before pasting anything inside the PRE block, and make sure "Use HTML in this post" check box is checked.
 Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
 Please do not post links to your question into an unrelated forum such as the lounge. It will be deleted. Likewise, do not post the same question in more than one forum.
 Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
 If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
 No advertising or soliciting.
 We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
cheers,
Chris Maunder
The Code Project Cofounder
Microsoft C++ MVP






Sorry, but it would take far too much time and space to explain that code in detail. If you do not understand the C language there are plenty of online tutorials, or you could find a book on Amazon. Alternatively, you could go back to StackOverflow and ask the person who wrote it.





Actually i just asked to explanation code which green sign sembol answer from stackoverflow . I try to ask my question with using comment but need 50 reputation .





You should ask the person who posted the code on Stackoverflow. This is CodeProject.





I have a table with 2 columns; here’s two typical examples:
TABLE 1 TABLE 2
X Y X Y
46.3 16.0 50.3 71.2
40.1 28.1 43.6 117.7
34.0 154.0 36.9 165.7
27.8 171.8 30.2 176.9
21.6 178.0 23.5 179.2
15.4 166.2 16.8 173.3
9.3 120.1 10.1 149.3
3.1 2.0 3.4 86.2
3.1 28.6 3.4 67.0
9.3 80.7 10.1 72.8
15.4 147.7 16.8 93.5
21.6 175.5 23.5 151.7
27.8 162.6 30.2 112.9
34.0 120.2 36.9 80.4
40.1 49.4 43.6 67.7
46.3 15.4 50.3 71.4
In the table 1, the Y decreases, while in the table 2 the Y increases. But notice the ambiguity in the table 1 for Y= 150 and in the table 2 for Y= 70.
I generate one table at runtime (I plan to use from 20 to 50 rows), the column Y is an angle (I use radians from –pi to pi and double precision number, but here I used degrees for the sake of simplicity).
The program generates an angle from –pi to pi and I need to find the two X’s that bracket the angle. For example, if the angle is 150, for the table 1 the function should find [15.4, 9.3] and [27.8, 34.0].





Let us consider, 100n + 5 = O(n). For this function there are multiple n_0 and c possible.
Solution1: 100n+5 ≤100n+n=101n≤101n,for all n ≥5,n_0=5 and c=101 is a solution.
Solution2:100n+5≤100n+5n=105n≤105n,for all n≥1,n_0=1 and c=105 is also a solution





Thank you for that bit of enlightenment.
The difficult we do right away...
...the impossible takes slightly longer.






The difficulty of understanding when and how it began.





Thanks for replying!





But how could time "begin"? Surely that implies a transition from one state to another, which requires the concept of "time" to already exist.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
 Homer





The scientists tell us it started with an enormous bang.





But again, "started" requires the concept of time to already exist.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
 Homer





Hey, I didn't invent big bang. I'm only repeating what they say happened: space and time did not exist, then they did. Go figure (as the scientists probably don't say).





Setting the date on my watch.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal





Can you please elaborate?






Time to rehash Stroustrup's computer/phone comment?
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012





Hello everyone,
I have been struggling since previous month about some question that I found on some university,
and I just cant think about a good way to solve it.
Please, help me to think about a way to solve this question.
The most important thing is that the solution has to work as fast as it can with the lowest complexity
that possible.
The question :
Quote: Vik the puffin is planning a long road trip around the circle road in Iceland, during which he wants to visit
all the landmarks along a path of length L. The tank of Vik's car can take up to F units of fuel and for every
unit of distance covered, his car consumes a unit of fuel. Using Google maps, Vik knows how far each of
the N gas stations are from the beginning of the path and the price per fuel unit each station offers. At the
starting point he has T units of fuel in his car.
1. Task
Write a program that will accept the above information and will calculate the minimum amount of money
Vik needs to spend on gas. If the journey is impossible to make, it should print 1.
2. Input
The first line contains four space separated integers:
N (0 < N < 50001): The total number of gas stations
F (0 < F < 1000001): The units of fuel Vik's car can take
T (0 <= T <= F): The units of fuel Vik's car has at the beginning of the trip
L (0 < L < 1000000001): The path length of the landmarks he plans to visit
Each of the following N lines will contain two integers: the first one, D_i (0 <= D_i <= L) corresponds
to the distance of the station from the starting point, and the second one, C_i (1 <= C_i <= 1,000,000)
represents the cost per fuel unit for that station.
Note: You may assume that the trip will be on a straight line where all gas stations are
spread on this line at the positions specified by their D_i values.
3. Output
The minimum amount of money to be spent or with 1 in case the trip is not feasible.
Note: There is a newline character at the end of the last line of the output.
4. Sample input
4 20 6 34
4 40
18 15
10 7
20 12
2
5. Sample output
348
6. Explanation
The rst line of the input is 4 20 6 34 which means that:
a. There are in total N=4 gas stations on the route
b. The (max) fuel capacity of Vik's car is F=20 liters
c. The tank currently has T=6 liters of gas
d. Vik wants to travel L=34 kms in total
Then the details for the 4 gas stations are provided in the form Di Ci, where Di is the distance of this
gas station from the starting point and Ci is the cost per liter of gas:
4 40
18 15
10 7
20 12
For simplicity assume that the whole trip is done in a straight line as depicted below:
link to show the trip from the example > Vik The Puffin — imgbb.com[^]
Obviously Vik does not have enough fuel for all 34 kms, so he needs to refuel. The cheapest gas station is
the one labeled (B) above, however Vik does not (initially) have enough fuel in his tank to reach (B), since
BS = 10 and he has T=6. So he needs to add an extra 4 liters from gas station A, so that he can the make
it until gas station B to get as much (cheap) as he can in order to make his 34 km journey. Thus he pays
(i) 4lt * 40$/lt = 160¿ and now he can make it until (B). Since until this moment he has only traveled
10 kms, he needs gas for another 3410=24kms. Normally he would want to refuel his car with 24 liters
(since B is the cheapest gas station) but since his (max) fuel capacity is F=20 liters he will only take 20
liters and thus pay (ii) 20 lt * 7 $/lt = 140$. He knows however that up to point (B) he has only traveled
10kms and he needs to travel another 24kms to reach his goal, whereas he has gas for 20kms. So he would
have to stop at a later gas station (after he has traveled at least 4kms) to refuel another 4 liters of gas so
that he could complete the whole 34 kms journey. Since he now has quite some gas, he may decide whether
he wants to refuel at (C) or at (D) and since (D) is cheaper, it is more than 4kms away from (B) and is
within reach (based on his gas in the tank) he will choose to refuel another 4 liters at (D) and thus pay (iii)
4lt*12$/lt=48$). After that he can successfully reach the end point of his trip.
PLEASE HELP ME WITH THIS!
Thanks in advance!





Quote: The most important thing is that the solution has to work as fast as it can with the lowest complexity
that possible.
I think the most important thing is that the solution "works"; worry about performance later.
Try a flow chart.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal





Member 13870192 wrote: I have been struggling since previous month about some question that I found on some university, ..but mysteriously cannot link to..
It's a straightforward problem. Create a class called Vic, and have him go on each possible route, calculating the costs on the way. Select the cheapest, and done. It is a naive bruteforce solution that I called "travelling Orca's". Since it resembles having an Orca in a Taxi take the actual route and phone back the results. Is as quick and efficient as the name suggests, but it works, and is a very good starting point to explain possible optimizations.
Member 13870192 wrote: The most important thing is that the solution has to work as fast as it can with the lowest complexity
that possible. The TSP thingy has been done to death. If you skipped class, that's your problem. You are fishing for free labor.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics."  Some Bell.





In particular I need tutorials on heuristic algorithms concerning graphs like pagoda function, bidirectional search etc. Also heuristic algorithms not concerning graphs. Introduction, pseudocode minimal amount of mathematics. In pdf or web page free of charge.





I usually only have time for one tutorial.
You will need to prioritize your requested items.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal



