Click here to Skip to main content
15,892,746 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionWM_QUERYENDSESSION problem on C++ Builder 2010 Pin
Member 88968923-May-10 7:06
Member 88968923-May-10 7:06 
AnswerRe: WM_QUERYENDSESSION problem on C++ Builder 2010 Pin
ARopo24-May-10 6:26
ARopo24-May-10 6:26 
GeneralRe: WM_QUERYENDSESSION problem on C++ Builder 2010 Pin
Member 88968924-May-10 13:36
Member 88968924-May-10 13:36 
QuestionC++ String Creation Pin
sikas_Cisco23-May-10 4:57
sikas_Cisco23-May-10 4:57 
AnswerRe: C++ String Creation Pin
Dr.Walt Fair, PE23-May-10 5:18
professionalDr.Walt Fair, PE23-May-10 5:18 
AnswerRe: C++ String Creation Pin
John R. Shaw23-May-10 7:21
John R. Shaw23-May-10 7:21 
GeneralRe: C++ String Creation Pin
sikas_Cisco23-May-10 8:55
sikas_Cisco23-May-10 8:55 
AnswerRe: C++ String Creation Pin
Aescleal23-May-10 9:36
Aescleal23-May-10 9:36 
The first thing to recognise is that when you're generating your strings you're just counting. Represent a by 0 and b by 1 and your example is:

00
01
10
11

And if you had three letter, a, m, z you could represent them by the digits 0, 1 and 2:

000
001
002
010
011
012
020
021
022
100
101
102
110
111
112
120
121
122
200
201
202
210
211
212
220
221
222

You're counting in base 2 in the a,b case, base 3 in the a,m,z case.

So you're going to get a number of solutions equal to the number of letters raised to the power of the number of letters - this gets big real quick. 4 letters has 256 combo, 5 letters has 3125 and so on.

For a brute force approach "all" you've got to do is:

- generate and the integers in the range ]0, n raised to the power of n]
- convert each number into a string of digits in base n
- convert each string of digits into a string of characters

This is one use of std::generate_n and two uses of std::transform.

With a bit more care you can collapse all three into call of std::generate_n with a bit of class building. I've wittered on enough for now - if you'd like more information just shout.

Cheers,

Ash
QuestionIntel Compiler IA-32 11.0.061 installation on VS 2010 question Pin
Chesnokov Yuriy23-May-10 4:07
professionalChesnokov Yuriy23-May-10 4:07 
QuestionOLE interface for Crichedit Pin
ForNow22-May-10 19:27
ForNow22-May-10 19:27 
Questionnew vs free and malloc vs delete Pin
msr_codeproject22-May-10 18:24
msr_codeproject22-May-10 18:24 
AnswerRe: new vs free and malloc vs delete Pin
loyal ginger22-May-10 19:01
loyal ginger22-May-10 19:01 
AnswerRe: new vs free and malloc vs delete Pin
Stephen Hewitt22-May-10 22:11
Stephen Hewitt22-May-10 22:11 
AnswerRe: new vs free and malloc vs delete Pin
Aescleal23-May-10 5:39
Aescleal23-May-10 5:39 
AnswerRe: new vs free and malloc vs delete Pin
John R. Shaw23-May-10 6:23
John R. Shaw23-May-10 6:23 
AnswerRe: new vs free and malloc vs delete Pin
MS_TJ23-May-10 19:52
MS_TJ23-May-10 19:52 
GeneralRe: new vs free and malloc vs delete Pin
Aescleal24-May-10 4:25
Aescleal24-May-10 4:25 
Questionopen txt file form web or ftp ? Pin
da_22-May-10 3:38
da_22-May-10 3:38 
AnswerRe: open txt file form web or ftp ? Pin
Richard MacCutchan22-May-10 4:28
mveRichard MacCutchan22-May-10 4:28 
AnswerRe: open txt file form web or ftp ? Pin
norish22-May-10 8:58
norish22-May-10 8:58 
AnswerRe: open txt file form web or ftp ? Pin
David Crow22-May-10 16:28
David Crow22-May-10 16:28 
GeneralRe: open txt file form web or ftp ? Pin
wangningyu23-May-10 5:43
wangningyu23-May-10 5:43 
AnswerRe: open txt file form web or ftp ? Pin
Hristo-Bojilov23-May-10 3:44
Hristo-Bojilov23-May-10 3:44 
GeneralRe: open txt file form web or ftp ? Pin
da_23-May-10 4:09
da_23-May-10 4:09 
GeneralRe: open txt file form web or ftp ? Pin
Hristo-Bojilov23-May-10 4:59
Hristo-Bojilov23-May-10 4:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.