|
That's the second site I've read that question on tonight.
|
|
|
|
|
|
javster87 wrote: Use your program to...
The operative word is YOUR.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Hello,
i need help with some C code.
lets say i have an array ..for example {1,3,2,5,10,11,8,7,9}
i need find the the largest part that gives me A[i] < A[i+1] < A[i+2]..
in this case its {2,5,10,11)
and the algorithm should return me the j that started this series of number (j=2)
what should i do?
i'd be glad if anyone can help me reaching the answer.
|
|
|
|
|
you again?
Farraj wrote: the largest part
define "largest part". is it the part holding the largest value; or having the most elements; or having the largest sum of elements; or...
whichever it is, reading the array sequentially will solve it; just calculate the current merrit, and remember the best so far.
|
|
|
|
|
I understand it as the longest sequence where a(i)<(a(i+1)<a(i+2) ...
<div="" class="signature">Watched code never compiles.
|
|
|
|
|
hi, thanks for ur reply
Farraj wrote: the largest part that gives me A[i] < A[i+1] < A[i+2]..
i mean the largest sequence of a[i] < a[i+1]..like 2 3 4 5
|
|
|
|
|
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
|
|
|
|