Click here to Skip to main content
15,911,141 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Thread and ActiveX component Pin
Farah Mansor20-Sep-01 15:58
Farah Mansor20-Sep-01 15:58 
GeneralRe: Thread and ActiveX component Pin
Ghazi H. Wadi21-Sep-01 16:09
Ghazi H. Wadi21-Sep-01 16:09 
GeneralRe: Thread and ActiveX component Pin
24-Sep-01 19:47
suss24-Sep-01 19:47 
Generalconsecutive sums Pin
minikg18-Sep-01 15:38
minikg18-Sep-01 15:38 
GeneralRe: consecutive sums Pin
Christian Graus18-Sep-01 16:02
protectorChristian Graus18-Sep-01 16:02 
GeneralRe: consecutive sums Pin
minikg18-Sep-01 16:04
minikg18-Sep-01 16:04 
GeneralRe: consecutive sums Pin
minikg19-Sep-01 12:28
minikg19-Sep-01 12:28 
GeneralRe: consecutive sums Pin
Christian Graus19-Sep-01 12:47
protectorChristian Graus19-Sep-01 12:47 
FWIW I'll start by telling you to do a less than or greater than sign into the forum you need to use shift-7 (ampersand) followed by gt or lt. If I just type what I just explained I get < >, but typing in the symbols gets stripped as an HTML tag. Also typing <pre> and </pre> allows you to format the code as you see below.

You're on the right track, but I thought you wanted to output actual sums, as in 1+6=2+5=3+4...=7 ?

To do that you will need to do this:

int value1 = input; // store value we will decrement

for (int value2 = 0; value2 <= input; ++value2, --value1)  // You can put mutiple statements into a for loop by using commans, this is true of any of the three parts involved.  You can also just put a ; if, for example, value2 was already set it could be for(;value2<=input;++value2, --value1)
{
    cout << value1 << " + " value2 << " = ";
}

cout << input << endl;


So what I am doing is maintaining a count from 0 to the input number, and another from the input number to 0. Adding one to one while removing one from the other means they will always add up to equal 'input', and so I can print the sum in a loop, finishing with the whole value.

I didn't test this code, so LMK if it doesn't work, or if there is something you do not understand (I'm not terribly good at explaining things Wink | ;) ).




Christian

As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.

Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
GeneralRe: consecutive sums Pin
minikg19-Sep-01 13:22
minikg19-Sep-01 13:22 
GeneralRe: consecutive sums Pin
Christian Graus19-Sep-01 14:23
protectorChristian Graus19-Sep-01 14:23 
GeneralRe: consecutive sums Pin
Christian Graus19-Sep-01 14:40
protectorChristian Graus19-Sep-01 14:40 
GeneralRe: consecutive sums Pin
Christian Graus19-Sep-01 14:42
protectorChristian Graus19-Sep-01 14:42 
GeneralRe: consecutive sums Pin
Christian Graus19-Sep-01 14:58
protectorChristian Graus19-Sep-01 14:58 
GeneralRe: consecutive sums Pin
Christian Graus19-Sep-01 16:32
protectorChristian Graus19-Sep-01 16:32 
QuestionHow do you remove help from a project? Pin
Cathy18-Sep-01 14:21
Cathy18-Sep-01 14:21 
AnswerRe: How do you remove help from a project? Pin
Tomasz Sowinski19-Sep-01 2:02
Tomasz Sowinski19-Sep-01 2:02 
GeneralRe: How do you remove help from a project? Pin
Cathy19-Sep-01 10:52
Cathy19-Sep-01 10:52 
Questionhelp, Implement Flashwindow like MNS Msg? Pin
OGIR18-Sep-01 12:30
OGIR18-Sep-01 12:30 
AnswerRe: help, Implement Flashwindow like MNS Msg? Pin
Michael P Butler18-Sep-01 22:21
Michael P Butler18-Sep-01 22:21 
Generalchar* as template parameter Pin
Aaron Schaefer18-Sep-01 12:22
Aaron Schaefer18-Sep-01 12:22 
GeneralRe: char* as template parameter Pin
Michael Dunn18-Sep-01 21:16
sitebuilderMichael Dunn18-Sep-01 21:16 
GeneralRe: char* as template parameter Pin
Aaron Schaefer19-Sep-01 3:48
Aaron Schaefer19-Sep-01 3:48 
GeneralDebug vs Release Pin
18-Sep-01 11:58
suss18-Sep-01 11:58 
GeneralRe: Debug vs Release Pin
Tomasz Sowinski19-Sep-01 1:06
Tomasz Sowinski19-Sep-01 1:06 
GeneralWin32 Printing Problems - 32character device names. Pin
Mike Doner18-Sep-01 11:19
Mike Doner18-Sep-01 11:19 

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.