#define _CRT_SECURE_NO_WARNINGS 1
#include"stdio.h"
#include"iostream"
int main()
{
char ch = '1';
int count = 0, x = 1;
while (ch != '\n')
{
scanf("%c", &ch);
if (ch == '{')
{
printf("%c", ch);
count++;
}
else if (ch == '}')
{
printf("%c", ch);
count--;
if (count < 0)
x = -1;
}
}
if (x == -1)
printf("不正确成对出现\n");
else if (count == 0)
printf("正确成对出现\n");
system("pause");
return 0;
}
花括号能否正确配对,有没有大神帮忙看一下对不对,十分感激
最新推荐文章于 2022-04-15 10:55:23 发布