/*
Row Editor
Http://acm.tongji.edu.cn/people/ps/showproblem.php? Problem_id = 1015
Time Limit: 1 s Memory Limit: 1000 k
Total Submit: 4424 Accepted: 1364
Problem
The function of a simple row editing program is to accept the program or data entered by the user from the terminal and store it in the user's data zone.
When a user inputs data on a terminal, no error is guaranteed, it is obviously not the most appropriate practice to "store each character in the user data zone. A good practice is to set up an input buffer to accept a line of characters entered by the user and store them in the user data zone row by row. You can enter a business error and correct the error in time. For example, if you find that the entered character is incorrect, you can add a backslash (#) to indicate that the previous character is invalid;
If you find that the number of errors in the current row is large or difficult to remedy, you can enter a fallback character "@" to indicate that the characters in the current row are invalid.
If the '#' symbol already entered at the beginning of the row is invalid.
Input
Enter a multi-line character sequence. The total number of characters (including the return and return characters) is not greater than 250.
Output
The output is as follows.
Sample Input
whli##ilr#e(s#*s) outcha@putchar(*s=#++);
Sample Output
while(*s)putchar(*s++);
*/
# Include <stdio. h>
# Define MAX_STK_SIZE 250
Int top;
Char stk [MAX_STK_SIZE];
Void InitStk ()
{
Top = 0;
}
Void TraverseStk ()
{
Int I;
For (I = 0; I <top; I ++)
Printf ("% c", stk [I]);
Printf ("/n ");
}
Int Pop (char * elem)
{
If (top = 0)
Return 0;
Else
{
Top --;
* Elem = stk [top];
Return 1;
}
}
Int Push (char elem)
{
If (top = MAX_STK_SIZE)
Return 0;
Else
{
Stk [top] = elem;
Top ++;
Return 1;
}
}
Int main ()
{
Int num;
Char CH, ELEM;
Initstk ();
While (num = getchar ())! = EOF)
{
Ch = (char) num;
If (CH = '#')
Pop (& ELEM );
Else if (CH = '@')
Initstk ();
Else if (CH = '/N ')
{
Traversestk ();
Initstk ();
}
Else
Push (CH );
}
Return 0;
}