Click here to Skip to main content
15,867,568 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: hello guy my name is SARORN can i ask you about any inform? Pin
Victor Nijegorodov24-Jun-22 5:51
Victor Nijegorodov24-Jun-22 5:51 
AnswerRe: hello guy my name is SARORN can i ask you about any inform? Pin
k505424-Jun-22 6:27
mvek505424-Jun-22 6:27 
AnswerRe: hello guy my name is SARORN can i ask you about any inform? Pin
RedDk24-Jun-22 8:42
RedDk24-Jun-22 8:42 
Questionc++ Pin
tuanguyen200021-Jun-22 22:59
tuanguyen200021-Jun-22 22:59 
QuestionRe: c++ Pin
CPallini22-Jun-22 0:02
mveCPallini22-Jun-22 0:02 
Questionc++ Pin
tuanguyen200021-Jun-22 6:49
tuanguyen200021-Jun-22 6:49 
AnswerRe: c++ Pin
tuanguyen200021-Jun-22 6:50
tuanguyen200021-Jun-22 6:50 
GeneralRe: c++ Pin
James Curran21-Jun-22 7:29
James Curran21-Jun-22 7:29 
Ok, so it appears the rules of this game are:
- If a number is a perfect square, take its square root
- if a number is divisible by 3, divide it by 3
- if a number is divisible by 2, divide it by 2
- otherwise, subtract 1.

So, given an input of 32, we'd go 32 -> 16 -> 4 -> 2 -> 1 -> 0 for 5 steps.
and given 75, we'd go 75 -> 25 -> 5 -> 4 -> 2 -> 1 -> 0 for 6 steps.

Now, what problem are you having? A quick glance over the code didn't show any obvious errors.

Your checkSquareNumber() and squareNumber() functions are quite inefficient. You'd be better off googling a better square root algorithm (or just using the library sqrt() function). Ad since they are doing the same thing, they could be combined (return -1 if it is not a perfect square, and you can replace the two calls with one)
Truth,

James

GeneralRe: c++ Pin
tuanguyen200021-Jun-22 14:53
tuanguyen200021-Jun-22 14:53 
GeneralRe: c++ Pin
CPallini21-Jun-22 20:20
mveCPallini21-Jun-22 20:20 
GeneralRe: c++ Pin
tuanguyen200021-Jun-22 22:50
tuanguyen200021-Jun-22 22:50 
GeneralRe: c++ Pin
tuanguyen200021-Jun-22 22:51
tuanguyen200021-Jun-22 22:51 
GeneralRe: c++ Pin
CPallini21-Jun-22 23:08
mveCPallini21-Jun-22 23:08 
GeneralRe: c++ Pin
Richard MacCutchan22-Jun-22 1:20
mveRichard MacCutchan22-Jun-22 1:20 
QuestionMessage Closed Pin
16-Jun-22 5:53
Member 1496877116-Jun-22 5:53 
AnswerRe: parsing interactive text Pin
Mircea Neacsu16-Jun-22 8:09
Mircea Neacsu16-Jun-22 8:09 
AnswerRe: parsing interactive text Pin
trønderen16-Jun-22 10:52
trønderen16-Jun-22 10:52 
JokeRe: parsing interactive text Pin
Peter_in_278016-Jun-22 11:56
professionalPeter_in_278016-Jun-22 11:56 
AnswerRe: parsing interactive text Pin
Richard MacCutchan18-Jun-22 2:50
mveRichard MacCutchan18-Jun-22 2:50 
QuestionCan importing C++ DLL files in a C# project has a positive effect on the overall performance of the application? Pin
Code4Ever10-Jun-22 8:39
Code4Ever10-Jun-22 8:39 
AnswerRe: Can importing C++ DLL files in a C# project has a positive effect on the overall performance of the application? Pin
Dave Kreskowiak10-Jun-22 9:56
mveDave Kreskowiak10-Jun-22 9:56 
QuestionLoading DLL from file not PATH Pin
Valentinor8-Jun-22 22:59
Valentinor8-Jun-22 22:59 
AnswerRe: Loading DLL from file not PATH Pin
Victor Nijegorodov8-Jun-22 23:16
Victor Nijegorodov8-Jun-22 23:16 
GeneralRe: Loading DLL from file not PATH Pin
Valentinor8-Jun-22 23:48
Valentinor8-Jun-22 23:48 
GeneralRe: Loading DLL from file not PATH Pin
Victor Nijegorodov8-Jun-22 23:52
Victor Nijegorodov8-Jun-22 23:52 

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.