|
unsigned int findPrimePalindromes(unsigned int array[],int start, int end)
{
for (int loop=start; loop<=end; loop++)
{
if (ValueIsPrimePalindrome(array[loop]))
{
return (loop);
}
}
return (end+1);
}
The function "ValueIsPrimePalindrome" is left as an exercise for the reader...
There are three kinds of people in the world - those who can count and those who can't...
|
|
|
|
|
Well you know: a prime number has only 1 and itself as divisors...Then you should check if it is palindrome (and that's really a simple task).
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 actually wrote the program, and it works for all value except after 10 million...
I need to keep the check time into half, so for the polindrome part, I only check half the strlen...
But it still would do much help....
I know whats prime polindrome!
|
|
|
|
|
ayeosq wrote: it works for all value except after 10 million...
Maybe you're running out of memory?
|
|
|
|
|
|
FILE* f = _wfopen(m_sFilespecW.c_str(),L"w");
size_t no = fwrite(tmp,sizeof(wchar_t),size,f);
fclose(f);
but it shows garbage.
when i change the code to:
FILE* f = _wfopen(m_sFilespecW.c_str(),L"w");
while(*tmp)
{
fputwc(*tmp,f);
tmp++;
}
fclose(f);
it saves the file but in ANSI format. it then fails to load in other function as that function only loads unicode files.
help me i want to save it in UNICODE.
|
|
|
|
|
What was wrong with the earlier reply?
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
See here and here.
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]
|
|
|
|
|
Also, he might want to see here[^]
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
I can get the device's status with c# every 15 milliseconds( more or less),but I want to get C++ code (not c++.net)which has realize SNMP++.
who can help me?Thank you!
|
|
|
|
|
There are several APIs available for SNMP on Windows.
WinSNMP Functions[^]
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
I am developing an application that has to act on external data that is both described and provided by the user, the client.
Currently I have created a wizard and the user can choose either to provide an SQL database (thus asking him for the DSN and the SQL query) or an XML file (thus asking him to for the appropriate xQuery query) or a CSV file (thus asking him for the file where it resides and the delimiting caracater).
Now, this may not be sufficient : I can imagine a plenty of complex scenario such the data cannot fall within those 3 types.
What I am tempted to do then is to make it possible for the application to call an external code provided by the user and which will be responsible for retrieving the data so that the application can deal with it.
My application is written in unmanaged C++, but the user may want to write that portion of code in JAVA, C# etc.
My only idea, which is unfortunately still not clear (regarding implementation) is to write a sort of specification of a COM object : user must write his data-code following that spec. and my application should be able to load available COM objects that fall with particular class and allow the user to select his implementation. Then the application is capable of calling that COM object and retrieving data passed by it.
(I am not even good at COM development)
So do you have suggestion, is there a sample application I can inspire from ?
Thank you in advance.
Easy Profiler : a compile-time profiler for C++
www.potatosoftware.com
|
|
|
|
|
If the COM-based idea is possible, the question then how would I deploy the specs ?
Would it be in form of an IDL file ?
Is it then possible to take an IDL file and construct a COM project from it ?
Easy Profiler : a compile-time profiler for C++
www.potatosoftware.com
|
|
|
|
|
Potato software wrote: My only idea, which is unfortunately still not clear (regarding implementation) is to write a sort of specification of a COM object : user must write his data-code following that spec. and my application should be able to load available COM objects that fall with particular class and allow the user to select his implementation. Then the application is capable of calling that COM object and retrieving data passed by it.
Well, the above idea is actually clear: Define one (or more) COM interface the user must implement (or expose COM interfaces from within your application).
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]
|
|
|
|
|
Thank you Pallini,
regarding the implementation I am then puzzled. Would it be an IDL file that describes the object interfaces ?
How is it possible let's say for example a Visual Studio C++ user to use an input IDL file in order to create a COM project ?
I can't see such options in the Wizard..
Easy Profiler : a compile-time profiler for C++
www.potatosoftware.com
|
|
|
|
|
You may use the MIDL output files (i.e. source files or type library, depending on the programming language). See, for instance [^].
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]
|
|
|
|
|
That's what I am looking for. Exactly. The type of info that can be used both in the consumer application (the COM client which is mine) and the COM server to be written by the user in the language he favors.
Thousand thanks.
Easy Profiler : a compile-time profiler for C++
www.potatosoftware.com
|
|
|
|
|
why dont you write the data in a xml-file, and use it as input for the app. Is it too easy?
Stay away from COM because you have to write both interface sides. I like COM very much for dealing with complex Collaboration as Internet Explorer or Networking.
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
Hi and thank you for your answer.
The problem is that data is expected to be very very large.
Your idea is good : I can ask the user to gather data in a definite XML schema.
But the goal is to enable the data retrieval and its processing to be , how can I say it, to be streamlined.
Thus if user has a sql database, instead of precessing it into a huge XML file, then passing it to my program , rather the program could ask a COM instance to gather the processed data, one by one and more importantly the program can distribute processing among many CPUs.
I don't know, well the data is expected to be big. or let me create a COM interface because I love it.
Easy Profiler : a compile-time profiler for C++
www.potatosoftware.com
|
|
|
|
|
if you have hugh data you have every time problems. Than it is best to split the data into different files. For instance in binary files (as images) which are stored with a path (or an identifier) in the object data.
Splitting data is always good idea, because you wont work and change all data at one time.
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
my code is:
FILE* f = _wfopen(m_sFilespecW.c_str(),L"w");
size_t no = fwrite(tmp,sizeof(wchar_t),size,f);
fclose(f);
but it shows garbage.
when i change the code to:
FILE* f = _wfopen(m_sFilespecW.c_str(),L"w");
while(*tmp)
{
fputwc(*tmp,f);
tmp++;
}
fclose(f);
it saves the file but in ANSI format. it then fails to load in other function as that function only loads unicode files.
help me i want to save it in UNICODE.
|
|
|
|
|
Hi Qoi,
I believe, before you flush your caracters, you must first write the BOM signature.
I encountered this problem before, but instead of using the windows API like write and open, instead I was
using the STD ofstream data structure, but I think the rule is the same :
first the file is opened in BINARY mode :
ofstream fout;
fout.open(fileTo.c_str(), ios_base::out | ios_base::trunc | ios_base::binary);
Then the BOM is written :
fout.write("\xEF\xBB\xBF", 3); // write UTF-8 Byte Order Mark (BOM)
Followed by your data here before calling close.
Hope this helps.
Easy Profiler : a compile-time profiler for C++
www.potatosoftware.com
|
|
|
|
|
Your first code snippet is probably correct.
You may not have installed the correct language pack to view the unicode characters and so it is showing it as garbage.
In the second case, you need to add a header to indicate that the file is unicode.
In windows the following headers are added -
For UTF-8 encoding the first 3 bytes of the file must be EF BB BF .
For UNICODE encoding the first 2 bytes of the file must be FF FE .
The characters I have shown are hexadecimal.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
hello;
i want to remove page orientation from print setup and make its default to landscape;
how can i do it?;
thanx;
|
|
|
|