【HDOJ】1699 The comment in cpp

注意测试数据
1
2
/*hduacm
// abcd
结果是
1
/*hduacm
// ABCD

 /* 1699 */
#include <iostream>
#include <sstream>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <deque>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <climits>
#include <cctype>
#include <cassert>
#include <functional>
#include <iterator>
#include <iomanip>
using namespace std;
//#pragma comment(linker,"/STACK:102400000,1024000") #define sti set<int>
#define stpii set<pair<int, int> >
#define mpii map<int,int>
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define rep(i, a, n) for (int i=a;i<n;++i)
#define per(i, a, n) for (int i=n-1;i>=a;--i)
#define clr clear
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define lson l, mid, rt<<1
#define rson mid+1, r, rt<<1|1 const int maxn = ;
const int maxl = ;
char ss[maxl];
char s[maxn * maxl];
char d[maxn * maxl];
int n, len; void solve() {
int l = ;
int i, j, k;
bool flag;
int ans = ; i = ;
while (i < len) {
if (s[i]=='/' && s[i+]=='*') {
j = i;
i += ;
flag = false;
while (i < len) {
if (s[i]=='*' && s[i+]=='/') {
flag = true;
i += ;
break;
}
++i;
} if (flag) {
++ans;
while (j < i) {
d[l++] = islower(s[j]) ? s[j]-'a'+'A' : s[j];
++j;
}
} else {
i = j;
d[l++] = s[i++];
d[l++] = s[i++];
} } else if (s[i]=='/' && s[i+]=='/') {
++ans;
while (i<len && s[i]!='\n') {
d[l++] = islower(s[i]) ? s[i]-'a'+'A' : s[i];
++i;
}
} else {
d[l++] = s[i++];
}
}
d[l] = '\0'; printf("%d\n%s\n", ans, d);
} int main() {
ios::sync_with_stdio(false);
#ifndef ONLINE_JUDGE
freopen("data.in", "r", stdin);
freopen("data.out", "w", stdout);
#endif int t; scanf("%d", &t);
while (t--) {
scanf("%d%*c", &n);
len = ;
rep(i, , n) {
gets(ss);
int sslen = strlen(ss);
rep(j, , sslen)
s[len++] = ss[j];
s[len++] = '\n';
}
s[len] = '\0';
solve();
} #ifndef ONLINE_JUDGE
printf("time = %d.\n", (int)clock());
#endif return ;
}
上一篇:防御XSS攻击的七条原则


下一篇:Netsharp快速入门(之19) 平台常用功能(插件操作)