-->
当前位置:首页 > 题库

PROGRAMMING:Symbol pairing

Luz5年前 (2021-05-10)题库401
Please write a program to check whether the following symbols in C language source program are matched: '/ *' and '* /', '(` and', '[` and'] ',' {'and'} '.
###Input format:
Input as a C language source program. When you read a line with only one period and a carriage return, it marks the end of the input. No more than 100 symbols need to be checked in the program.
###Output format:
First, if all symbols are correctly paired, output 'yes' in the first line, otherwise output' no '. Then point out the first unpaired symbol in the second line: if the left symbol is missing, output '- Right symbol '; If the right symbol is missing, the 'left symbol -?' is output.
###Input sample 1:
```in
void test()
{
int i, A[10];
for (i=0; i<10; i++) /*/
A[i] = i;
}
.
```
###Output sample 1:
```out
NO
/*-?
```
###Input example 2:
```
void test()
{
int i, A[10];
for (i=0; i<10; i++) /**/
A[i] = i;
}]
.
```
###Output example 2:
```
NO
?-]
```
###Input sample 3:
```
void test()
{
int i
double A[10];
for (i=0; i<10; i++) /**/
A[i] = 0.1*i;
}
.
```
###Output example 3:
```
YES
```






answer:If there is no answer, please comment