|
Have you used the debugger to step through the code watching s and num ?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
i haven't looked at the debugger messages, maybe i should, but as a beginner i may not even know what i am seeing so i will look into this. thanks
|
|
|
|
|
HI
Would U plz help me with this Code
I cant find the Error !!
here's the Question:-http://uva.onlinejudge.org/external/1/136.html[^]
here's the code .. "that shows a wrong output"
#include<iostream>
#include<list>
using namespace std;
int main ()
{
int uglylist[1500];
uglylist[0]=1;
int maximum;
int max2=0;
int max3=0;
int max5=0;
for(int i = 1; i<1500; i++)
{
maximum =uglylist[i-1];
for(int j=0;j<=i;j++)
{
if (uglylist[i]>max2)
{
max2=uglylist[j]*2;
break ;
}
if (uglylist[i]>max3)
{
max3=uglylist[j]*3;
break ;
}
if (uglylist[i]>max5)
{
max5=uglylist[j]*5;
break ;
}
uglylist[i]=min(max2,min(max3,max5));
}
}
cout<<uglylist[1500-1]<<endl;
}
So Would U plz help ?
|
|
|
|
|
Would U plz do your own homework?
|
|
|
|
|
well actually i didnt ask u to do it for me
& i guess u can c that i've already written the code
if u can help .. just do it
else :- dont come to disturb my post !!
|
|
|
|
|
anollipian wrote: i've already written the code
No. You have written some code, however your algorithm is flawed.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
anollipian wrote: So Would U plz help ?
Have you used the debugger to step through the code? Narrow the problem down from 1,500 to something more manageable.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
Hi,
I have got 2 errors one saying:
this line contains a '{' which has not yet been matched
end of file found before the left brace '{
<br />
#include <windows.h><br />
<br />
#define WINDOW_WIDTH 903<br />
#define WINDOW_HEIGHT 729<br />
<br />
const char lpClassName[] = "MyProject";<br />
HWND mainWindow;<br />
<br />
LRESULT CALLBACK WindowEvent(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);<br />
<br />
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)<br />
{<br />
WNDCLASSEX wc;<br />
wc.style = CS_VREDRAW | CS_HREDRAW;<br />
wc.lpszMenuName = NULL;<br />
wc.lpszClassName = lpClassName;<br />
wc.lpfnWndProc = WindowEvent;<br />
wc.hInstance = hInstance;<br />
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);<br />
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);<br />
wc.hCursor = LoadCursor(NULL, IDC_ARROW);<br />
wc.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH);<br />
wc.cbWndExtra = 0;<br />
wc.cbSize = sizeof(wc);<br />
wc.cbClsExtra = 0;<br />
<br />
<br />
RegisterClassEx(&wc);<br />
<br />
mainWindow = CreateWindowEx(<br />
NULL,<br />
lpClassName,<br />
"My Project",<br />
WS_OVERLAPPEDWINDOW | WS_VISIBLE,<br />
0,<br />
0,<br />
WINDOW_WIDTH,<br />
WINDOW_HEIGHT,<br />
NULL,<br />
NULL,<br />
hInstance,<br />
NULL<br />
);<br />
<br />
if (!mainWindow)<br />
return 0;<br />
<br />
UpdateWindow(mainWindow);<br />
<br />
MSG msg;<br />
<br />
while (1)<br />
{<br />
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))<br />
{<br />
if (msg.message == WM_QUIT)<br />
<br />
TranslateMessage(&msg);<br />
DispatchMessage(&msg);<br />
}<br />
<br />
<br />
return (int) msg.wParam;<br />
}<br />
LRESULT CALLBACK WindowEvent(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)<br />
{<br />
switch (message)<br />
{<br />
case WM_DESTORY:<br />
PostQuitMessage(0);<br />
return 0;<br />
break;<br />
<br />
<br />
return DefWindowProc(hWnd, message, wParam, lParam);<br />
}<br />
<br />
<br />
Andrew McIntyre
|
|
|
|
|
you need to close the { in that last switch
|
|
|
|
|
You also forgot to close braces after while(1)
(add another after the translate,dispatch pair)
|
|
|
|
|
Could you show me on the code where to place the { symbol as I am kinda struggling to locate it.
If you can create quick snippet of the part of the code so I can just copy that fix into my source code.
Thanks
Andrew McIntyre
|
|
|
|
|
Sure thing.
There's actually another one that neither of us mentioned yet too - you mean WM_DESTROY, not WM_DESTORY
Substitute part of your code for this:
while (1)
{
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if (msg.message == WM_QUIT)
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return (int) msg.wParam;
}
LRESULT CALLBACK WindowEvent(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_DESTROY:
PostQuitMessage(0);
return 0;
break;
}
return DefWindowProc(hWnd, message, wParam, lParam);
}
There's other things amiss too, though this will give you a window that opens.
|
|
|
|
|
Thanks very much you guy's. Its much appreciated.
Andrew McIntyre
|
|
|
|
|
If you are using VS6, click Ctrl+] to locate matching braces (which will indirectly show you unmatched braces). I know there's a similar way in VS200x, but I don't know it off the top of my head.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
I've seen functions defined as:
int SetIniString(int nConfigSet, char *Section, char *Key, const char *format, ... );
Could someone explain what the '...' in the parameter list means and does?
|
|
|
|
|
|
Thank you David, for the explanation and link!
|
|
|
|
|
Paul Belikian wrote: Could someone explain what the '...' in the parameter list means and does?
It means that the function also accepts zero or more parameters following the last named parameter. The function will then use some information passed by the caller (in this case the %x specifications in the format string) and the va_arg[^] functions, to access the extra parameters.
|
|
|
|
|
Thank you too Richard, I appreciate your response!
|
|
|
|
|
hi all
i am developing an application in which i need to find a sector that does not allocated space by a file or folder.
|
|
|
|
|
Yeah, I know. You told us all about it over the course of the last week.
What have been your advances in this time? What suggestions have been usefull/useless? What have you found out about FAT and NTFS since then?
You do realize, don't you that FAT is a 'simple' format, and all you have to do is look at the File Allocation Table to see which sectors are used by which files. If a sector's not in the list of used sectors, guess what? It's not used.
There's enough info in the File Allocation Table page at Wikipedia to do the FAT work.
|
|
|
|
|
enhzflep wrote: There's enough info in the File Allocation Table page at Wikipedia to do the FAT work.
That just doesn't sound right.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
Oops!
|
|
|
|
|
Are you looking for an empty disk sector? On what type of file system?
Best Wishes,
-David Delaune
|
|
|
|
|
Hello all ,
As windows Vista and windows 2008 have all come with an option of "Run as Administrator", Is there some way to programmatically invoke some executable so as it could be invoked as 'Administrator' ?
Regards,
Kushagra
|
|
|
|