|
Hi,
But is there any wrong logic I have used in the code? OR
Can you suggest me the proper logic, if I am wrong.
Thanks for your replay.
Thanks & Best Regards,
Aniket A. Salunkhe
|
|
|
|
|
How to create several files of integers to be used to test sorting.several sizes, for example, size 20, 200, and 2000. Make files that are in order, in reverse order, in random order, and partially in order. By keeping all this test data in files (rather than generating it with random numbers each time the program is run), the same data can be used to test different sorting methods, and hence it will be easier to compare their performance.
the code template
template<class t="">
void insertionsort(T data[],int n)
{
for(int i=1,j;i<n;i++){
t tmp="data[i];
for(j=i;j">0&&tmp
|
|
|
|
|
The easiest way is to use an empty project with Doc/View arquitecture.
In the CMyDoc::Serialize (it comes by default using the assistant) you can code directly your random functions to save the ints that you want.
If not...
You should use the CFile,
CFile f;
if (!f.Open ("FileName.ext", CFile::modeRead))
{
}
if (!f.Open ("FileName.ext", CFile::modeWrite))
{
}
Sample to write numbers
void CMyView::WriteFile (CFile* file)
{
int Array[LIM];
for (int i = 0; i < lim; i++)
{
}
int* pBuf;
pBuf = &Array[0];
file->Write (pBuf, sizeof (Array));
}
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
thank you M.D.V...well but I have here no idea how to start the coding..can you please do teach me
|
|
|
|
|
Sorry, but Im not going to make your job. I have given you the idea to do it. You should now try it by yourself and post when you have problems, we will help you. But you hav to show you are trying it.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
Thanks i understand you are guiding me,but it this correct what i'm doing now.Please have a look and if there is mistakes please correct me.
Thank you.
#include<iostream.h>
#include<ctime>
#include<math.h>
CFile f;
if (!f.Open ("FileName.ext", CFile::modeRead))
{
//Read your ints
}
if (!f.Open ("FileName.ext", CFile::modeWrite))
{
//Write your ints
}
void CMyView::WriteFile (CFile* file)
{
int Array[LIM];
for (int i = 0; i < lim; i++)
{
//fill with random
}
int* pBuf;
pBuf = &Array[0];
file->Write (pBuf, sizeof (Array));
}
void insertionsort(T data[],int n)
{
for(int i=1,j;i
T tmp=data[i];
for(j=i;j>0&&tmp
data[j]=data[j-1];
data[j]=tmp;
}
}
void main()
{
int x, y, z;
int arr[];
getArray (arr, n);
cout<<"The array before sorting was"<<endl;
="" for="" (x="0;" x<n;="" x++)
=""
="" {
="" cout<<arr[x]<<'="" ';
="" }
="" cout<<endl;
="" insertionsort="" (arr,="" n);
="" cout<<"the="" array="" after="" sorting="" was="" (assending)"<<endl;
="" (y="0;" y<n;="" y++)
="" cout<<arr[y]<<'="" (decending)"<<endl;
="" (z="n;" z="">=0; z--)
{
cout<
|
|
|
|
|
Just some advices...
1) Use "< pre > your code < /pre >" for snippets of code biggers than some lines, and "< code > your sentence < /code >" to highlite sentences in red (as I made). The first tags make:
it would be easier for us to read
2) The best way to do it is... you make your program, you compile in your computer. Try to solve your errors (can be missings ; or easy things) and... if you don't know what is happening... THEN write us the error that your compiler says, and the piece of code where the compiler sends you when you double click on the error.
If we need more information... we will ask you to give us more code or to answer concrete questions we make
About your code...
I have write a guide, not a functional code... // This 2 shlashes means that, up to this point all the things in the line are COMMENTED, so is not going to be read/compiled.
So... you have to try there, a piece of valid code. I mean (and I do one thing) with this:
for (int i = 0; i < lim; i++)
{
}
has to be done something, for example...
srand( (unsigned)time( NULL ) );
for (int i = 0; i < lim; i++)
{
myArray[i] = rand ();
}
With that you fill an array with LIM - 1 positions with random numbers.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
Nelek wrote: The easiest way is to use an empty project with Doc/View arquitecture.
Gotta love driving nails with a sledgehammer!
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
snoop82 wrote: How to create several files of integers to be used to test sorting.several sizes, for example, size 20, 200, and 2000. Make files that are in order, in reverse order...
Do you have access to Excel?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Well if you have a pseudo random generator and it's always initialized with the same seed than you will always generate the same sequence of numbers!!!
Thus it's possible to do the performance comparison test you are taking about.
---
Yours Truly, The One and Only!
devmentor.org
Design, Code, Test, Debug
|
|
|
|
|
Hi i am working on a dialog box in a MFC application in VC 6.0 I want to use a simple button on which there is no text written instead a bmp image is drawn. what i actually need is that the image of button will change on mouse over,mouse down,mouseup etc. I need help of you people to solve this problem.
Thanks
|
|
|
|
|
You must draw the different images yourself in the OnPaint() function and check your conditions. Search for ownerdrwan buttons (XPButton)
This is the way not the solution...
Greetings from Germany
|
|
|
|
|
Try to find 'BtnST' class on this site. All you have to do is place a button on dialog, delete all text and in your .h file(wich you added to yours project) declare them as 'CButtonST' (a.g. CButtonST m_btnMY). It take this much code in yours cpp:
m_btnMY.SetIcon(IDI_ICON10);
m_btnMY.SetFlat(TRUE);
m_btnMY.SetTooltipText(_T("some text"));
and that is it!!!
You could do a whole lot more... just reed the article and take at look at sample!
|
|
|
|
|
Fine idea, but I was not the asker.
Greetings from Germany
|
|
|
|
|
I'm sorry, I didn't mean to send this to you. When I clicked replay I meant generally to original post. Once again sorry!
|
|
|
|
|
Thaks a lot dear fellow
your suggestion really helped me a lot.
looking forward for further collaboration.
Regards
|
|
|
|
|
Happy I could help!
Be aware of an a little bug I discovered, tooltips working fine before you press the button, but after that (when whatever code you run under the button press ends) tooltips do not appear any more so you have to put them back:
void CMyDlg::OnBtnMY() <br />
{<br />
m_btnMY.SetTooltipText(_T("some text"));<br />
}<br />
|
|
|
|
|
|
can you please tell me which visual studio you are working in ?
Also check the font of your editor, may be it got changed.
Do a test -
Copy some text from vc editor which contains " and ?.
Paste it in notepad. Now check if notepad shows the original characters.
Also do the reverse of it, Copy text from notepad and paste in vc editor.
Are the characters got changed now also ?
|
|
|
|
|
|
Good to hear that 
|
|
|
|
|
|
hey !
this is a forum, not a chat.
you don't have to repost the same question[^] again. just wait !
delete this and wait until someone knows your answer.
and don't forget GOOGLE and MSDN are your friends
|
|
|
|
|
You were faster :P
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
Nelek wrote: You were faster
that'w what makes me a CodeProject Fixture
|
|
|
|