Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Algorithms and flowcharts (Yet another C++ assignment).
#10
Steps 4 and 5 aren't switches, you are just reading numbers.
Something like this
(pseudocode because I'm too lazy to draw a flowchart and too mean to write your actual code for you :-P )
Code:
read two numbers into i and j;
  if (both are positive) or (both are negative)
    terminate with "bad input" error;
  if (i is positive)
    place i into lineNumber and j into wordNumber;
  else
    place j into lineNumber and i into wordNumber;

The switch comes in when you have to put the word in the right place, so step 7, and it looks like this
Code:
switch (lineNumber)
{
     case 1: place the word in text.line1; break;
     case 2: place the word in text.line2; break;
     case 3:....
     default: exit with "bad input" error;
}

(note that this is butt-ugly and I hope the purpose of the exercise is to show you how much unnecessary work you have to do when you choose the wrong data structure).
Reply


Messages In This Thread
Algorithms and flowcharts (Yet another C++ assignment). - by SaptaZapta - 2013-09-24, 04:55 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)