|
Try sorting all #s first. Then for each element in list 1, search for a match in list 2. Upon finding it, remote the item from both lists. So if there are 3 50's in list 1 and 8 50's in list 2, you should be left with 0 in list 1 and 5 in list 2.
Then with your new list 1 and 2, try to reconcile the largest items first. You should do sweeps assuming that an item in list is the sum of two #s. Then after trying this for all items, then look at sums of three #s...
You will loop over the combinations using (d-1) dimensional arrays where d is the # of items in the sum.
Note that this does not guarantee that it will find the right solution.... The correct algorithm is more complex.
You could mark each # as being utilized for sum of k #s in the other list. Then you have to search multiple cases until you find your most explanatory match...
Depending on what other information you have, there may be an even better method.
|
|
|
|
|
Both of replies are very helpful. I think I have got the point. Thank you very very much.
Md. Humayuon Kabir Hemoo
|
|
|
|
|
when i am executing following code:
#include "stdafx.h"
#include "stdio.h"
#include
using namespace std ;
class Derived;
typedef void (Derived::*callbackf)() ;
class Base;
typedef map<base*, callbackf*=""> MYLIST;
class Base
{
public:
Base(void){};
MYLIST mylist;
void Attach(Base* p, callbackf* voidpt){mylist[p] = voidpt;};
~Base(void){};
};
class Derived : public Base
{
public:
void onMoving(){};
Derived(void)
{
callbackf ponMoving = &Derived::onMoving;
Attach(this, &ponMoving);
};
~Derived(void){};
};
int _tmain(int argc, _TCHAR* argv[])
{
Base *b;
b= new Derived();
MYLIST::iterator itr;
itr = b->mylist.begin();
for (itr = b->mylist.begin(); itr != b->mylist.end(); itr++)
{
Base* clsOb = (*itr).first;
callbackf fn = b->mylist[(*itr).first];
(*clsOb.*fn)();
}
return 0;
}
I am getting two errors:
'initializing' : cannot convert from 'void *' to 'callbackf'
'newline' : cannot convert from 'Base *__w64 ' to 'Derived *__w64 '
'.*' : cannot dereference a 'callbackf' on a 'Base'
Can anybody pls help?
modified on Sunday, November 22, 2009 11:38 PM
|
|
|
|
|
Could you please format your code using the "code block" tag (and please, read the posting guidelines at the top of this message board).
|
|
|
|
|
I have tried to compile this code and get 35 errors. I think you need to work on correcting the basics, particularly the typedefs at the beginning.
|
|
|
|
|
I've got DLL which invokes SHGetSpecialFolderPath() function with CSIDL_LOCAL_APPDATA parameter in DLL load handler.
When the DLL is loaded from windows application, ASP.NET application, or windows service and queried that special folder, it returns different locations for that special folder. Moreover in XP and Vista those locations are different.
Is there a way to find out these locations with some specific function when invoked from windows application?
Чесноков
|
|
|
|
|
Correct me if im wrong but SHGetSpecialFolderPath() returns a userrelated folder. The organization of users is different on XP then under Vista. This is the reason you will get different folders. But what is your problem with that?
Rozis
|
|
|
|
|
yes, user related folder, I know it is different.
>>Is there a way to find out these 3 locations with some specific function when invoked from windows application?
Чесноков
|
|
|
|
|
Chesnokov Yuriy wrote: >>Is there a way to find out these 3 locations with some specific function when invoked from windows application?
No function may be available to do this. Because you are trying to access a different user's profile directory, what if the user is an Active Directory user account, and user profile's directory is on a network drive?
What are you trying to implement? there should be some better solution than accessing another user's profile directory.
-Suhredayan
|
|
|
|
|
I need a special folder that already has r/w access for particular user on that computer (either ASP.NET user, service application user, windows application user)
Чесноков
|
|
|
|
|
Chesnokov Yuriy wrote: I need a special folder that already has r/w access for particular user on that computer (either ASP.NET user, service application user, windows application user)
Do you mean a user_profile directory where all the three users have read/write access? if then use: CSIDL_COMMON_APPDATA with SHGetSpecialFolderPath()
-Suhredayan
|
|
|
|
|
in Vista it points to c:\ProgramData and it is not write access enabled
Чесноков
|
|
|
|
|
Chesnokov Yuriy wrote: in Vista it points to c:\ProgramData and it is not write access enabled Smile
My bad, I assumed it being all user's profile folder, every user may have read/write permission to it. But on a second thought if that was true - then it would introduces security issues - imagine if a non-admin user logs in to the machine and installs an .exe into all_user's_startup folder. Next time administrator logs-in, the same .exe would run under administrator's security privilege.
This might be one reason the default location/name of this folder is changed in Vista, to make more sense.
It seems you may need to create/identify a folder, and have the permission set during the installation - either through your program, or as instruction to the person installing your app. That is the best I can think of - I know that might be something you may already have in your mind as a last option.
-Suhredayan
|
|
|
|
|
Hi...
My code is....
FILE *obj1;
CString str1;
char out[90000000];
char out1[90000000];
int numreturn, i = 0;
obj1 = fopen("txtfile.txt","r++");
numreturn=fread(out,sizeof(char),90000000,obj1);
str1.Format("%s",out);
i = str1.find("somestring");
It shows error.
How to convert char[array] to CString for huge values?
thanks...
G.Paulraj
|
|
|
|
|
char out[90,000,000];
The above variable goes to stack, by default stack size is limited to a far less size than that by the compiler.
-Suhredayan
|
|
|
|
|
Is there any otherway to convert from c[90000000] to CString?
Thanks...
G.Paulraj
|
|
|
|
|
Paulraj G wrote: Is there any otherway to convert from c[90000000] to CString?
Sorry I don't know if something like that can be done. However here [^] is an sample code/algorithm I found through Google, that may help you.
-Suhredayan
|
|
|
|
|
gnanapaul wrote: How to convert char[array] to CString for huge values?
*That* isn't what your problem is! If you're using MFC, you'll do far better by using CString and CFile . Don't you think?
I don't understand the point of writing C-Style code within MFC. There can be no justification for such insanity.
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
There's no need for such large buffers.
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]
|
|
|
|
|
gnanapaul wrote: char out[90000000];
char out1[90000000];
If you have to use such large buffers, then I think something is wrong with your code. I advise you revise your design a bit. Why for instance do you need to read the file in one huge chunk ?
|
|
|
|
|
But if you want to continue on your road replace char out[90000000] with a call to memalloc() (and memfree()). And in align with previous answers you could study what memory-mapped files are...
Rozis
|
|
|
|
|
gnanapaul wrote: char out[90000000];
Replace this with:
char *out = new char[90000000];
gnanapaul wrote: char out1[90000000];
Remove this.
"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
|
|
|
|
|
Thanks...
char *out = new char[90000000];
Its working...
G.Paulraj
|
|
|
|
|
I am working on a project to create a Visual C++ application that loads a grayscale image (bitmap) and performs basic image processing tasks like Zooming/Shrinking, Histogram equalization, basic filtering in both spatial and frequency domains, noise reduction etc. Now I have some basic exposure to C++ coding before but I've never worked with VC++ before and am completely lost trying to build the "app" from the code (which typically involves operating with the pixels). I am told MFCs are the way to go, but it seems too complex for a beginner.
So I was just wondering if someone can help me/point me towards a place where I can get a sort of a basic skeleton MFC which, say has the window and the menus (with the various tasks) designed and can open an image file and extract the pixels from it.
I hope it's not too much to ask for. I am an Electrical Engineer by background and have had not much coding experience before and although I have the logic for this project figured out, I'm running into a brick wall when it comes to coding it. Any help will be much appreciated. Thank you.
|
|
|
|
|
vishal_c wrote: I am an Electrical Engineer by background
Heh - me too.
Run Visual Studio and select File/New/Project to open the new project dialog. Select VC++, MFC, then MFC Application.
You're probably going to want a Single Document Interface (SDI) project type (but mabe not... depends on what you have in mind). This'll generate a skeleton project for you. There are a lot of project options you can specify; play around and seen the differences in the wizard-created code for the various options.
There's also a fairly decent tutorial called 'Scribble' that demonstrates a lot of the basics of VC++ project development. If you have the time, it's worth working your way through it.
|
|
|
|