
I gave more than what you asked for in your query. Now it's up to you to use it.
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_





It should be in maths blog.Anyway Use the logic given below.....i hope it will help u
The Basic Steps
The basic steps for a date in the years 20002099 are as follows:
Example date July 13th, 2004
1. Take the last 2 digits of the year and add a quarter onto itself. (04 + 1 = 5)
2. Get the corresponding code for the month. (January = 6, February = 2, March = 2, etc. See month codes for details). July = 5
3. Take the day. (=13)
4. Add the numbers together (5 + 5 + 13 = 23)
5. Take away 7 (or multiples of 7) until a number from 17 is left. (23  21 =2)
6. This number corresponds to the day of the week. (1 = Monday, 2 = Tuesday, etc.) In this case 2 = Tuesday
The basic steps  Other points  Month codes  Leap years  Gregorian calendar  Shortcuts  Examples  Other methods  Books  Links  Whose idea?
Other points to take into account
Apart from the basic steps, other elements have to be taken into account:
* When adding a quarter of the year onto itself, If the quarter of the year is not a whole number, simply ignore the decimals. Do not round up. Therefore 27/4 = 6.75 = 6, and 2/4 = 0.5 = 0.
* Leap years: subtract 1 from the total if the month is January or February.
* Negative numbers. During the calculation you get 0 or negative numbers, just add seven until you get a number from 17.
* Different "centuries" *.
o 1700s add 5
o 1800s add 3
o 1900s add 1
o 2100s subtract 2
o 2200s subtract 4
(* For this method we have to consider a '00' year as part of the new century)
The basic steps  Other points  Month codes  Leap years  Gregorian calendar  Shortcuts  Examples  Other methods  Books  Links  Whose idea?
The codes for the months
At first the hardest part is learning the codes for the months. They are as follows:
Jan Feb Mar Apr. May Jun Jul Ago Sept Oct Nov Dec
6 2 2 5 0 3 5 1 4 6 2 4
Try to use some memory system to remember the codes for the months. for example, February is the 2nd month, March 2 music, etc. Try to find associations that will remind you.
If need be, you can add 7 or multiples of 7 to any of these values to help you remember them. For example, August could be 1 or 8, and as it is the 8th month, it may be easier to remember with 8 than with 1. This may be useful if you can match it with a wellknown date. You could remember that the code for December is 25 (4+21), or for someone's birthday. The negative aspect of this is that you'll be taking away the 7 (or multiples) towards the end of the calculations, and you'll be working with bigger numbers.
The basic steps  Other points  Month codes  Leap years  Gregorian calendar  Shortcuts  Examples  Other methods  Books  Links  Whose idea?
Leap Years
* Remember that leap years are not always every 4 years. There are exceptions. Years that end in 00 are not leap years unless it is a multiple of 400. Therefore 1700, 1800, 1900, and 2100 are not leap years, but 2000 is.
The basic steps  Other points  Month codes  Leap years  Gregorian calendar  Shortcuts  Examples  Other methods  Books  Links  Whose idea?
The Gregorian Calendar
* The calendar as we know it only came into effect (in England) in 1752, replacing the Julian calendar. Changes included cutting 11 or more days out of the calendar and changing the first day of the year from march 21st to January 1st, and so this calculation method should not be used for dates before this changeover.
* Unfortunately, not everyone agreed to the change at the same time. The change was in fact officially enacted in 1582, but only some catholic countries actually did change at this time. After this other countries took their time before accepting the change. Great Britain in 1752, Japan in 1873 and China (the last) in 1949. In several cases, such as Germany, only some regions changed at a time, and Sweden removed the days one by one over a long time.
* The overall result of this is that for centuries, each country had its own system, and dates did not fall on the same day. if you are looking at a date, you need to take into account if it was before the changeover in that country, and take into account the 10 (or more) days removed from the calendar, the the fact that the years used to start on a different day.
The basic steps  Other points  Month codes  Leap years  Gregorian calendar  Shortcuts  Examples  Other methods  Books  Links  Whose idea?
Shortcuts
There are several shortcuts that can be used to simplify and speed up the process so that you can calculate the result almost immediately.
* When working out the year, remember that as the calendar repeats itself every 28 years within each "century", we can subtract 28 or multiples of 28 (56 or 84) so it is easier to add a quarter on to the year if it is a smaller number. Therefore 1996 is the same as 199684 =1912. It is much easier to add a quarter of 12 onto itself, than a quarter of 96. In this way, the greatest number you will have to work with is 27.
* When the year is a multiple of 4, such as 16, it is very easy to add a quarter (16/4=4 16+4 =20.). Some people may have problems when the number is not a multiple of 4. (e.g. 27/4). Because we do not need the decimals in the result, the easiest and quickest way is to take the nearest multiple of 4 below the number, and calculate a quarter of that, adding it onto the year. (e.g. 1927: the nearest multiple of 4 below this is 24. 24/4=6. add 6 to 27 to get 33.) Many people may find this easier than working out the division and then eliminating the decimals (27/4=6.75. eliminate the decimals to get 6. add 6 to 27 to get 33)
* It is good practice to subtract 7 or multiples of 7 at this point rather than adding on the month and the day before doing it. The same is true for the day. This is because it is easier to recognize and subtract multiples of 7 from smaller numbers.
* Simply remembering the final year code for the current year and the coming year makes instant calculations possible, as calculating the year code is the timeconsuming process. For the years 20002003, the numbers correspond to the last digit of the year. This is a very quick method.





Wow, so you would code all of this instead of simply using an existing class (like COleDateTime for instance) that does all of that for you ?







Simply providing a link would have sufficed:
http://www.terra.es/personal2/grimmer/[^]
"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 guys,
I have two vectors of string
and I'm looking for an easy way to find the first vector sequence or subsequence into the first one
for example:
Vect_1 < "JAVA", "ADA", "C", "C++", "C#">
Vect_2 < "C++", "C#">
search vect_2 sequence in vect_1 will return vect_1 position 3 and match length 2
Vect_1 < "JAVA", "ADA", "C", "C++", "C#">
Vect_2 < "JAVA", "C#">
search vect_2 sequence in vect_1 will return vect_1 position 0 and match length 1
thanks for any idea, suggestion





Are you simply wanting to know how to search a vector ?
"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





it's a little bit more complicated
I'm looking for a way to search a vector into an other vector
std::set_intersection can do it, but in my case I have to respect the order of the sequence





kaminem wrote: ...search a vector into an other vector
What does this mean?
"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 want to search vect_2 into Vect_1
for example
Vect_1 < "JAVA", "ADA", "C", "C++", "C#">
Vect_2 < "C++", "C#">
here vect_1 contain all vect_2 elemnts and in the some order
but if I don't find the entire sequence I should look for a subsequence too (and this is my big pb)
I'm trying to avoid the use of for loop





solution
use of std::search





Hello Everyone,
I have Demo MFC application, with 2 buttons Start and End Button.
Start button will start 2 threads
void CThreadDemoDlg::OnStart()
{
HANDLE hr1,hr2;
hr1 = CreateThread(NULL,0,(unsigned long (__stdcall *)(void *))WorkerThreadOne,this,0,0);
hr2 = CreateThread(NULL,0,(unsigned long (__stdcall *)(void *))WorkerThreadTwo,this,0,0);
}
UINT WorkerThreadOne(LPVOID Param)
{
fstream OutFile;
OutFile.open("FileOne.txt",ios::out);
for(int i=0;i<10000;i++)
OutFile << i << " ";
OutFile.close();
return true;
}
Can anyone please tell me how to kill the thread ? OnEnd click.
Thanking you,
Suresh.





First of all, you must use AfxBeginThread, if you're using MFC[^].
void CThreadDemoDlg::OnEnd(){
SetEvent(hEndAllEvent);
}
UINT WorkerThreadXYZ(LPVOID pParams){
fstream OutFile;
OutFile.open("FileOne.txt",ios::out);
for(int i=0;i<10000;i++)
{
if(WaitForSingleObject(hEndAllEvent, 0) == WAIT_OBJECT_0) break;
OutFile << i << " ";
}
OutFile.close();
return FALSE;
}
Have a look at WaitForSingleObject[^]
It is a crappy thing, but it's life ^ Carlo Pallini





Hello Everyone,,
Sorry saw all yr response now.Thanks a lot for the reply.
I am very much new to the Thread Concept. thought of learning the basics of threads.
can anyone suggest me some nice Article to start with.
Thanking you,
Suresh





There are plenty of articles around, but before all that, do you have a book on MFC programming? If not, please buy one. My book recommendations for MFC are here[^]
Essay recommendation:
Worker Threads[^]
UI Threads[^]
There are plenty of articles at CP as well, just do a search.
It is a crappy thing, but it's life ^ Carlo Pallini





Message Closed
modified 14Oct15 22:14pm.





You can forget Terminate*(TerminateThread/TerminateProcess).
MSDN:
TerminateThread is a dangerous function. Use it only in the most extreme cases.
Why 1.00/5 ???
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
modified on Tuesday, April 14, 2009 5:54 AM





That's probably one of the worst way to do that. You should never call TerminateThread (unless in very specific conditions). In general, there are much better ways to achieve what you want.





Hi Parag Patel,
Thanks for the reply.
I tried with this below code but still the thread is running its not terminated,
can u please tell how to kill the thread.
void CThreadDemoDlg::OnEnd()
{
TerminateThread(hr1,1);
TerminateThread(hr2,1);
}





Having looked at your code in your first post, I can tell you that you MUST NOT use TerminateThread(). It's saddening to see you've picked the worst suggestion that was given to you.
It is a crappy thing, but it's life ^ Carlo Pallini





Rajesh R Subramanian wrote: It's saddening to see you've picked the worst suggestion that was given to you.
That's usually the case because it looks like the easiest solution





Maybe you didn't see the replies to his post but it is strongly recommanded not to use TerminateThread.
A better approach would be to pass a pointer to your dialog class to the thread function, and within the thread cast it back to your dialog and call a public function on it. Inside that function you put the code you already provided except that in your loop, you also check if a flag is set or not (this flag is a simple bool which is a member of the dialog). If the flag is set, you simply stop the loop and the function terminates.
When you click on the end button, you can simply set this flag so that the loop stops.





Hello Cédric Moonen,,
Sorry saw yr response now.Thanks a lot for the reply.
I am very much new to the Thread Concept. thought of learning the basics of threads.
can anyone suggest me some nice basic Article to start with.
Thanking you,
Suresh





This[^] article is one of the best I know of.




