Sirena400

Feb 22, 2005, 08:48 PM

*sighs* I got a big problem, because the other students in my class acted up for the substitute while my teacher was gone, my teacher now has forbidden us to go into the computer lab until he thinks we're ready again, so now I have to pay for the other kid's actions because we still have to do programs, but now we just have paper and pencil to work with and I don't have any help from the computer. *sighs* So I don't know whether or not this code works or not, could someone look it over and tell me whether or not it looks okay?

The problem is we have to figure out the most undo buffers ever needed in a sequence of actions. C will stand for the user changing the data set, U will stand for the user undoing the most recent change, R will stand for the user redo an action(ie. cancelling the most recent Undo), and S will stand for the user saving the data set. I gave each letter a number value that'll make it easier, C equal 1, U will equal -1, R will equal 1, and S just resets the added up value to zero again. Some examples are:

CCCCCCCC -> this would require 8 buffers because the that's the most the data was changed another harder example is:

CCCCURUUCSCUCUS so using the values i set up, the first CCCC = 4, subrtract 1 for the U which leaves the current score at 3, add 1 for the R making the current score 4 again, minus 2 for the next two U's making the current = 2, add 1 for the C which makes current = 3, then S resets that to 0, and the next set of CUCU cancels each other out and the S at the end resets it to 0. so throughout that sequence, the highest number of times the data was changed was 4 times(right at the beggining) so the session requires 4 undo buffers because that was the most that was changed. hopefully you guys get what i'm saying ^^;

so here's what I have so far:

#include<iostream.h>

int main()

{

char letter;

cin>>letter;

int current=0;

int max=0;

switch(letter)

{

case 'C': current+=1;

break;

case 'U': current-=1;

break;

case 'R': current+=1;

break;

default:

break;

}

If current>max

then current=current

If current<max

then current=max

If current=max

then current=current

cout<<"This session requires "current" undo buffers.";

return 0;

}

I have no idea if this is right, but this is what I have so far. Also, I can't figure out how to set it up that max equals the highest number that was added up during the sequence of action and how to set it so the current is reset to 0 when S appears. Any and all help would be very greatly appreciated! Thanks!

The problem is we have to figure out the most undo buffers ever needed in a sequence of actions. C will stand for the user changing the data set, U will stand for the user undoing the most recent change, R will stand for the user redo an action(ie. cancelling the most recent Undo), and S will stand for the user saving the data set. I gave each letter a number value that'll make it easier, C equal 1, U will equal -1, R will equal 1, and S just resets the added up value to zero again. Some examples are:

CCCCCCCC -> this would require 8 buffers because the that's the most the data was changed another harder example is:

CCCCURUUCSCUCUS so using the values i set up, the first CCCC = 4, subrtract 1 for the U which leaves the current score at 3, add 1 for the R making the current score 4 again, minus 2 for the next two U's making the current = 2, add 1 for the C which makes current = 3, then S resets that to 0, and the next set of CUCU cancels each other out and the S at the end resets it to 0. so throughout that sequence, the highest number of times the data was changed was 4 times(right at the beggining) so the session requires 4 undo buffers because that was the most that was changed. hopefully you guys get what i'm saying ^^;

so here's what I have so far:

#include<iostream.h>

int main()

{

char letter;

cin>>letter;

int current=0;

int max=0;

switch(letter)

{

case 'C': current+=1;

break;

case 'U': current-=1;

break;

case 'R': current+=1;

break;

default:

break;

}

If current>max

then current=current

If current<max

then current=max

If current=max

then current=current

cout<<"This session requires "current" undo buffers.";

return 0;

}

I have no idea if this is right, but this is what I have so far. Also, I can't figure out how to set it up that max equals the highest number that was added up during the sequence of action and how to set it so the current is reset to 0 when S appears. Any and all help would be very greatly appreciated! Thanks!