zoukankan      html  css  js  c++  java
  • 【HDOJ】1699 The comment in cpp

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

      1 /* 1699 */
      2 #include <iostream>
      3 #include <sstream>
      4 #include <string>
      5 #include <map>
      6 #include <queue>
      7 #include <set>
      8 #include <stack>
      9 #include <vector>
     10 #include <deque>
     11 #include <bitset>
     12 #include <algorithm>
     13 #include <cstdio>
     14 #include <cmath>
     15 #include <ctime>
     16 #include <cstring>
     17 #include <climits>
     18 #include <cctype>
     19 #include <cassert>
     20 #include <functional>
     21 #include <iterator>
     22 #include <iomanip>
     23 using namespace std;
     24 //#pragma comment(linker,"/STACK:102400000,1024000")
     25 
     26 #define sti                set<int>
     27 #define stpii            set<pair<int, int> >
     28 #define mpii            map<int,int>
     29 #define vi                vector<int>
     30 #define pii                pair<int,int>
     31 #define vpii            vector<pair<int,int> >
     32 #define rep(i, a, n)     for (int i=a;i<n;++i)
     33 #define per(i, a, n)     for (int i=n-1;i>=a;--i)
     34 #define clr                clear
     35 #define pb                 push_back
     36 #define mp                 make_pair
     37 #define fir                first
     38 #define sec                second
     39 #define all(x)             (x).begin(),(x).end()
     40 #define SZ(x)             ((int)(x).size())
     41 #define lson            l, mid, rt<<1
     42 #define rson            mid+1, r, rt<<1|1
     43 
     44 const int maxn = 105;
     45 const int maxl = 205;
     46 char ss[maxl];
     47 char s[maxn * maxl];
     48 char d[maxn * maxl];
     49 int n, len;
     50 
     51 void solve() {
     52     int l = 0;
     53     int i, j, k;
     54     bool flag;
     55     int ans = 0;
     56     
     57     i = 0;
     58     while (i < len) {
     59         if (s[i]=='/' && s[i+1]=='*') {
     60             j = i;
     61             i += 2;
     62             flag = false;
     63             while (i < len) {
     64                 if (s[i]=='*' && s[i+1]=='/') {
     65                     flag = true;
     66                     i += 2;
     67                     break;
     68                 }
     69                 ++i;
     70             }
     71             
     72             if (flag) {
     73                 ++ans;
     74                 while (j < i) {
     75                     d[l++] = islower(s[j]) ? s[j]-'a'+'A' : s[j];
     76                     ++j;
     77                 }
     78             } else {
     79                 i = j;
     80                 d[l++] = s[i++];
     81                 d[l++] = s[i++];
     82             }
     83             
     84         } else if (s[i]=='/' && s[i+1]=='/') {
     85             ++ans;
     86             while (i<len && s[i]!='
    ') {
     87                 d[l++] = islower(s[i]) ? s[i]-'a'+'A' : s[i];
     88                 ++i;
     89             }
     90         } else {
     91             d[l++] = s[i++];
     92         }
     93     }
     94     d[l] = '';
     95     
     96     printf("%d
    %s
    ", ans, d);
     97 }
     98 
     99 int main() {
    100     ios::sync_with_stdio(false);
    101     #ifndef ONLINE_JUDGE
    102         freopen("data.in", "r", stdin);
    103         freopen("data.out", "w", stdout);
    104     #endif
    105     
    106     int t;
    107     
    108     scanf("%d", &t);
    109     while (t--) {
    110         scanf("%d%*c", &n);
    111         len = 0;
    112         rep(i, 0, n) {
    113             gets(ss);
    114             int sslen = strlen(ss);
    115             rep(j, 0, sslen)
    116                 s[len++] = ss[j];
    117             s[len++] = '
    ';
    118         }
    119         s[len] = '';
    120         solve();
    121     }
    122     
    123     #ifndef ONLINE_JUDGE
    124         printf("time = %d.
    ", (int)clock());
    125     #endif
    126     
    127     return 0;
    128 }
  • 相关阅读:
    docker知识复习
    记住left join最简单的方式(转)
    ingress rewrite 配置文件的结构 + server_name和location这两条指令的配置来匹配要 虚拟主机
    PAM unable to dlopen(/lib/security/pam_limits.so): /lib/security/pam_limits.so: wrong ELF class: ELFCLASS32
    iRedMail退信问题的解决(转)
    curl NSS error -8179 (SEC_ERROR_UNKNOWN_ISSUER)
    看进程的启动时间长度 + vmstat + jstack 应用
    Nginx日志中的金矿
    php-fpm参数优化
    PHP扩展--opcache安装及配置
  • 原文地址:https://www.cnblogs.com/bombe1013/p/5124253.html
Copyright © 2011-2022 走看看