文件名称:ProgramA
-
所属分类:
- 标签属性:
- 上传时间:2014-03-11
-
文件大小:636byte
-
已下载:0次
-
提 供 者:
-
相关连接:无下载说明:别用迅雷下载,失败请重下,重下不扣分!
介绍说明--下载内容来自于网络,使用问题请自行百度
括号匹配(二)
时间限制:1000 ms | 内存限制:65535 KB
难度:6
描述
给你一个字符串,里面只包含"(",")","[","]"四种符号,请问你需要至少添加多少个括号才能使这些括号匹配起来。
如:
[]是匹配的
([])[]是匹配的
((]是不匹配的
([)]是不匹配的
输入
第一行输入一个正整数N,表示测试数据组数(N<=10)
每组测试数据都只有一行,是一个字符串S,S中只包含以上所说的四种字符,S的长度不超过100
输出
对于每组测试数据都输出一个正整数,表示最少需要添加的括号的数量。每组测试输出占一行
样例输入
4
[]
([])[]
((]
([)]样例输出
0
0
3
2-Matching brackets (two)
Time Limit: 1000 ms | Memory Limit: 65535 KB
Difficulty: 6
Descr iption
Give you a string, which contains only "(", ")", "[", "]" Four symbols, what you need to add at least the number of brackets to make these brackets match up.
Such as:
[] Is matched
([]) [] Is matched
((] Is a mismatch
([)] Is a mismatch
Enter
The first line enter a positive integer N, the number of test data sets (N <= 10)
Each test is only one line, is a string S, S contains only four characters mentioned above, the length does not exceed 100 S
Export
For each test data outputs a positive integer indicating the minimum number needed to add parentheses. Each test output per line
Sample Input
4
[]
([]) []
((]
([)] Sample Output
0
0
3
2
时间限制:1000 ms | 内存限制:65535 KB
难度:6
描述
给你一个字符串,里面只包含"(",")","[","]"四种符号,请问你需要至少添加多少个括号才能使这些括号匹配起来。
如:
[]是匹配的
([])[]是匹配的
((]是不匹配的
([)]是不匹配的
输入
第一行输入一个正整数N,表示测试数据组数(N<=10)
每组测试数据都只有一行,是一个字符串S,S中只包含以上所说的四种字符,S的长度不超过100
输出
对于每组测试数据都输出一个正整数,表示最少需要添加的括号的数量。每组测试输出占一行
样例输入
4
[]
([])[]
((]
([)]样例输出
0
0
3
2-Matching brackets (two)
Time Limit: 1000 ms | Memory Limit: 65535 KB
Difficulty: 6
Descr iption
Give you a string, which contains only "(", ")", "[", "]" Four symbols, what you need to add at least the number of brackets to make these brackets match up.
Such as:
[] Is matched
([]) [] Is matched
((] Is a mismatch
([)] Is a mismatch
Enter
The first line enter a positive integer N, the number of test data sets (N <= 10)
Each test is only one line, is a string S, S contains only four characters mentioned above, the length does not exceed 100 S
Export
For each test data outputs a positive integer indicating the minimum number needed to add parentheses. Each test output per line
Sample Input
4
[]
([]) []
((]
([)] Sample Output
0
0
3
2
(系统自动生成,下载前可以参看下载内容)
下载文件列表
ProgramA.cpp
本网站为编程资源及源代码搜集、介绍的搜索网站,版权归原作者所有! 粤ICP备11031372号
1999-2046 搜珍网 All Rights Reserved.