ylxd41 2016-09-16 14:06 采纳率: 50%
浏览 1027

各位帮个忙,在此处真心谢谢了

第一行输入一个数N(0<N<=100),表示有N组测试数据。后面的N行输入多组输入数据,每组输入数据都是一个字符串S(S的长度小于10000,且S不是空串),测试数据组数少于5组。数据保证S中只含有"[","]","(",")"四种字符
输出
每组输入数据的输出占一行,如果该字符串中所含的括号是配对的,则输出Yes,如果不配对则输出No
样例输入
3
[(])
(])
([])
样例输出
No
No
Yes

代码如下:
// acm 括号配对.cpp : 定义控制台应用程序的入口点。
//输入样本个数和括号样本,看括号是否可以配成对

#include "stdafx.h"
#include

int _tmain(int argc, _TCHAR* argv[])
{
int n,a;
int w=0;
char*p;
int s;
char name[21];
printf("请输入样本个数:");
scanf("%d",&n);
for(int i=0;i {
printf("请输入测试样本:");
scanf("%s",name);
p=name;
s=strlen(name);
if(s%2!=0)//若输入样本为基数则不可能配对
printf("NO\n");
else
{
for(w=0;w {
if(*(p+w+1)==*((p+strlen(name)/2)-w-1))
continue;
else
{
break;
}
}
switch(a=(w>1))
{
case 1:
printf("YES\n");
break;
case 0:
printf("NO\n");
break;
}
}
}
return 0;
}

请各位大神看看,在某些情况下运行不对?
请告诉一下小弟。谢谢

另外付acm结果 错误信息如下:
./Source/main.cpp:4:20: error: stdafx.h: No such file or directory
./Source/main.cpp:7: error: ‘_TCHAR’ has not been declared
./Source/main.cpp: In function ‘int _tmain(int, int**)’:
./Source/main.cpp:14: error: ‘printf’ was not declared in this scope
./Source/main.cpp:15: error: ‘scanf’ was not declared in this scope

小弟是初学者,在此谢过。也在本站问答区问过,但是答案一直不对。麻烦大家了

  • 写回答

1条回答 默认 最新

  • threenewbee 2016-09-16 15:42
    关注
     #include "stdafx.h"
    删除
    
    int _tmain(int argc, _TCHAR* argv[])
    ->
    int main()
    
    加上@include <stdio.h>
    

    参考程序:http://blog.csdn.net/zwj1452267376/article/details/42424323?locationNum=1

    评论

报告相同问题?

悬赏问题

  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题