c/c++语言开发共享编写一个程序,它从标准输入(终端)读取C源代码,并验证所有的花括号都正确的成对出现。

#include<stdio.h> int main() { int cou=0; char ch; while((ch=getchar())!='n')

  #include<stdio.h>  int main()  {  int cou=0;  char ch;  while((ch=getchar())!='n')  {  if(ch=='{')  cou++;  else if(ch=='}')  {  if(cou==0)  printf("匹配不成功!");  cou--;  }  }  if(cou==0)  printf("匹配成功!");  else  printf("匹配不成功!");  return 0;  }  

 

本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

ctvol管理联系方式QQ:251552304

本文章地址:https://www.ctvol.com/c-cdevelopment/606702.html

(0)
上一篇 2021年5月14日
下一篇 2021年5月14日

精彩推荐