Advertisement

7-4 符号配对 (25 分) 数组模拟栈

阅读量:

习题3.8 括号匹配 (20 分)

输入格式:

The input represents a C language source program. When a single period followed by a carriage return is encountered during the parsing process, it signifies the termination of the input process. The program must ensure that the number of paired symbols does not exceed 100.

输出格式:

首先, 当所有字符正确配对时, 在第一行显示"YES"; 否则, 在第一行显示"NO"。
接着, 在第二行确定第一个未匹配的字符位置: 若无左字符, 则以"-?"标记右字符的位置; 若无右字符, 则以"?"-标记左字符的位置。

输入样例1:

void test()
{
int i, A[10];
for (i=0; i<10; i++) /*/
A[i] = i;
}
.

输出样例1:

NO
/*-?

全部评论 (0)

还没有任何评论哟~