|
I guess you need to sort in ascending order.
You can either code any of the sorting algorithm.
Or
You can put the array into a vector container and then call the sort function.
|
|
|
|
|
And what is your doubt about (just a couple of loops would suffice, at first sight)?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
one loop is all it takes, this is an O(n) job.
|
|
|
|
|
Yes, I realize you may complete it with just one loop and pair of variables.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
so you did read the hint[^]
|
|
|
|
|
Of course.
Now, plz gimme codez!
(urgentz)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
bubble sort and binary search
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
So you want to find the longest sub-sequence where the numbers are in ascending order?
I would loop through the array from item 1 to the last item, checking if the current item is larger than the previous item. You need to maintain the current ordered sequence length, which you would reset if you detect an item that's smaller than the previous one, and increment if the current item is bigger than the previous one. You also need to record the maximum ordered sequence length, which you would set to the current ordered sequence length when the current one is bigger than the maximum.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
CodeProject MVP for 2010 - who'd'a thunk it!
|
|
|
|
|
Thanks for ur replies
i've made one loop for the array that checks if v[i]
|
|
|
|
|
Good Afternoon I have an compilation error in my code with inline assembly.I want to get IVT(Interrupt Vector Table)Address using VC++ 2008 I have "Illegal 16 bits instruction" with line MOV AX,ES:[BX]. Can you help me please.
<br />
#define WORD unsigned short<br />
<br />
WORD address;<br />
<br />
__asm<br />
{<br />
push ES<br />
MOV AX,0<br />
MOV ES,AX<br />
MOV BX,address<br />
MOV AX,ES:[BX]
}<br />
Thank you.
|
|
|
|
|
AFAIK on recent Windows platforms assembly instructions operate by default on either 8-bit or 32-bit quantities, not 16-bit. And the 32-bit version of the CPU registers are called EAX, EBX, etc.
If you really want a 16-bit operation, you need a prefix instruction byte, I don't know what syntax it takes though.
|
|
|
|
|
Yes, I remember MS-DOS fondly. The Interrupt Vector Table was sitting at 0000:0000 to 0000:0400. Sorry to disappoint you, but things have changed a bit in the last 20 years or so.
I assume you're not programming for WinMe (I think that was the last operating system that supported this) or the 16-bit VDM (Which was probably disposed of in Windows Vista??) If you are, try to lay hands on an old copy of Visual C++. I think the GNU C compiler can still generate 16 bit code for real mode.
Have a look at this: Get interrupt vector information in Windows[^]
(This is probably only valid for 32-bit versions of Windows, the ULONG's look suspiciously short, but you'll probably find all the info in the latest and greatest DDK -- too lazy to look it up).
Oh, yes, before you ask (I just know this is coming): you cannot change this IDT, except in a device driver.
|
|
|
|
|
Can anyone provide me information about whitebox testing tools for Visual C++?
|
|
|
|
|
|
I couldn't find the right information about white box testing for vc++ application so thought of taking help from CP.
|
|
|
|
|
Wow, do you really want to write white box tests for Visual Studio?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
whitebox testing is my clients requirement. I am deseprately looking for tutorials and tools. I am very confused to write test stubs/drivers for vc++ code. It would be very helpful if you can provide me some info about whitebox testing in vc++.
|
|
|
|
|
Super Hornet wrote: Can anyone provide me information about whitebox testing tools for Visual C++?
better would be function testing using you demo project!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Does function testing require communication between demo project and main project?
|
|
|
|
|
Hi.. I am writing a RS-232 application with one worker thread. Please tell me what is the best method for invoking the AfxBeginThread. My ideas are,
1. Using SetTimer() method handle it in OnTimer
2. While(1) which is infinite loop
I thought both these methods are not efficient enough. Please tell me any other method for invoking AfxBeginThread.
Thanks in advance
msr_codeproject
|
|
|
|
|
Why do you need multiple AfxBeginThread calls (maybe I haven't got you?)?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I have a file to be sent over serial port. So every time I am reading that file using a structure and sending. For this I need to call AfxBegingThread till end of the file.
Thank u..
msr_codeproject
|
|
|
|
|
msr_codeproject wrote: For this I need to call AfxBegingThread till end of the file.
Are you sure you really understood the concept of threads ? You need to call AfxBeginThread only once. Then in your thread function, that's where you will send the file over the serial port.
|
|
|
|
|
Cedric Moonen wrote: You need to call AfxBeginThread only once
you need to call AfxBeginThread for each thread you want to create ? no ?
if I want to create 50 threads, I should call it 50 times ?
Watched code never compiles.
|
|
|
|
|
I just can see your 47 th thread handling the 47 th character to be sent over the serial line...
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|