Well previously I've asked a lot of question regarding Travelling Salesman Problem and I got a lot of helpful feedback from here. Thanks again for helping me.
Now I've completed the full code. Basically I'm implementing several searches on my code (Brute force, random search and heuristic search). So now I've to do some literature review on other searches that can also be implemented to solve this problem. Well, I'm not experienced...
User Profile
Collapse
-
Can someone kindly give me some guidance please? -
koolplot in C++
Greetings, I'm currently dealing with koolplot and here is my problem. I need to generate a graph which consist of 2 data, X-axis would be fixed, whereby it will range from -1 to 101. As for Y-axis, it will have the data stored inside the arrays. Now I need to plot one line showing the data of array and another line showing data of array1. The following is my current code but it can't generate a graph. It does not have any compilation error and I'm... -
The following is my code..
[PHP]#include <koolplot.h>
using namespace std;
int main()
{
double array[100];
int numberToInsert = 99;
for(int i=0; i<100.0; i++)
{
array[i] = i+1;
}
plotdata x(-20, 110),
y(array, numberToInsert) ;
plot(x,y);
return 0;
}[/PHP]
...Leave a comment:
-
Another question is do I have to put in the equation in order to plot the graph? What if I've an array storing all the data, can I plot the graph using that array?Leave a comment:
-
Plotting Graph in C++
Greetings, I'm currently having problem in plotting a simple graph in C++. I learned that we can actually use koolplot to do it. My question is whether it is possible to plot, let's say the performance of 6 algorithms into one graph? If so, how? Because when I refer to the koolplot documentation all I see is just plotting one thing at a time in a graph.
Thanks for any advice given. -
I see.. okay I'll try to implement it onto my code. Thanks a lotLeave a comment:
-
hmm... yes actually that's what I want. Because initially I've stored all the fruit's name into a string array and it's used by other function. And somewhere down the whole code, I need to compare character by character of the fruit's name. For example:
1. P A P A Y A
2. P E A C H
I need to compare "P" with "P", since it's the same, then I've to proceed on the second alphabet which is "A"...Leave a comment:
-
Convert String to char
Hi, currently I'm having a problem on converting a string type array into a char type. An example is as follows:
string fruits[20];
vector <char> temp;
The fruits array HAS to be a string type and temp vector HAS to be a char type. This can't be changed. So I've a problem on storing the element of fruits array into temp vector as follows:
temp.push_back( fruits[0]); <-----I know this is... -
Vector with char type
I'm currently having a confusion with storing characters into a vector. The problem is described as follows:
I've a string array which stores, let's say the names of the vegetables.
string vegeName[20];
and this array is stored fully with all the names. Then I need to store one of the element in this string array into a vector. The project itself is asking us to do so, so I've no choice. So this is what... -
I'm actually solving a TSP problem whereby I need to write a function to search the possible randomly. So I need to generate random numbers to help me choose which paths should I take in case there are more than 1 path. My current program is very very long already, so I don't know which snippet should I post it here. But anyway, thanks a lot for your advice. I think I've made some mistake in vectors due to random numbers. Because I'm using a lot...Leave a comment:
-
Or am I doing the wrong thing? without that line, rand() itself will generate numbers between 0~1 right? Because:
tempNUM = rand();
cout << "Random number generated is :" << tempNUM << endl;
and all I see is the same (for e.g) 0.41.
What will happen if I add srand((unsigned )time(0)), will the numbers being generated more than 1?Leave a comment:
-
No, it's not a compilation error. Well, before I add on that line, the program can run properly. But after I add on that line, the result shown on the command prompt is like an endless loop whereby the numbers are jumping non-stop.
Since after adding that line will make the numbers generated randomly, but I'm still setting a proper range for the numbers generated in order to get the range that I want. I can't understand why this line...Leave a comment:
-
Yes I understand that the range can be obtained as follows to get numbers between 1~3:
int randNum;
randNum = (rand()%3)+1;
But the problem I faced right now is, let's say I've add on a cout as follows:
cout << "Number generated: " << rand() << endl;
Let's give an example, when I run the program for the first time, the result is:
Number generated:...Leave a comment:
-
Generating random numbers
Greetings,
This is my second post till now. Thanks for all the advice given to me for the first post.
Now I'm having problem with generating random numbers. I know if we want to generate a random number, we can use:
int tempNUM = rand();
But, once I execute the program, the generated number is always similar, and I found this from the internet. It says need to add this line to make the... -
Vector Problem
Greetings,
I'm currently facing a problem on how to compare 2 vector's elements. For example, assuming we have declared 2 integer type vectors:
vector <int> v1;
vector <int> v2;
and both vectors have some integer values stored inside. What is the syntax that I can use to check such that all the elements in v1 and v2 are the same? Can I do the following? Do I need to declare something...
No activity results to display
Show More
Leave a comment: