首页 > ACM题库 > HDU-杭电 > Hdu 1699 The comment in cpp 待解决 [解题报告] C++
2013
12-21

Hdu 1699 The comment in cpp 待解决 [解题报告] C++

The comment in cpp

问题描述 :

In C++ ,there are two styles of comment, one is a stream of characters enclosed by "/*" and "*/", and the other is a single line beginning with "//". Comments will not be nested as in c++.
Your task is to deal with these comments, which is to capitalize all the letters in a comment and count the number of occurrence of comments.
To simplify your task, you may assume that comments will not appear in constant strings.

输入:

The first line speicifies the number of test cases T (T <= 10). Each test case begins with a number L (L <= 100), the number of lines of the C++ code, following L lines which is the body of the code. The length of each line of the code will not exceed 200.

输出:

For each test case, output the number occurrence of comments you’ve found and then the resulting text of your processing. print a line after each test case.

样例输入:

2
1
/*hduacm
1
/*hduacm //hduacm */

样例输出:

0
/*hduacm

1
/*HDUACM //HDUACM */


  1. a是根先忽略掉,递归子树。剩下前缀bejkcfghid和后缀jkebfghicd,分拆的原则的是每个子树前缀和后缀的节点个数是一样的,根节点出现在前缀的第一个,后缀的最后一个。根节点b出现后缀的第四个位置,则第一部分为四个节点,前缀bejk,后缀jkeb,剩下的c出现在后缀的倒数第2个,就划分为cfghi和 fghic,第3部分就为c、c

  2. 很高兴你会喜欢这个网站。目前还没有一个开发团队,网站是我一个人在维护,都是用的开源系统,也没有太多需要开发的部分,主要是内容整理。非常感谢你的关注。