zoukankan      html  css  js  c++  java
  • hdu 1736 美观化文字

    Problem - 1736

      模拟,不过好多地方要注意。

      对于每一行,左右双引号要重新计算,有可能有全角的双引号,也要算进去。

    代码如下:

     1 #include <cstdio>
     2 #include <cstring>
     3 #include <iostream>
     4 #include <algorithm>
     5 
     6 using namespace std;
     7 
     8 int main() {
     9     char str[2][3];
    10     strcpy(str[0], "");
    11     strcpy(str[1], "");
    12 //    freopen("in", "r", stdin);
    13     char ch = getchar();
    14     bool L = true;
    15     while (ch != EOF) {
    16         if (ch == '
    ') L = true;
    17         if (ch == ',') printf("");
    18         else if (ch == '.') printf("");
    19         else if (ch == '!') printf("");
    20         else if (ch == str[0][0]) {
    21             ch = getchar();
    22             if (ch == str[0][1]) {
    23                 if (L) printf("");
    24                 else printf("");
    25                 L = !L;
    26             } else {
    27                 putchar(str[0][0]);
    28                 continue;
    29             }
    30         } else if (ch == str[1][0]) {
    31             ch = getchar();
    32             if (ch == str[1][1]) {
    33                 if (L) printf("");
    34                 else printf("");
    35                 L = !L;
    36             } else {
    37                 putchar(str[1][0]);
    38                 continue;
    39             }
    40         } else if (ch == '"') {
    41             if (L) printf("");
    42             else printf("");
    43             L = !L;
    44         } else if (ch == '<') {
    45             ch = getchar();
    46             if (ch == '<') printf("");
    47             else {
    48                 putchar('<');
    49                 continue;
    50             }
    51         } else if (ch == '>') {
    52             ch = getchar();
    53             if (ch == '>') printf("");
    54             else {
    55                 putchar('>');
    56                 continue;
    57             }
    58         } else if (ch == '?') printf("");
    59         else putchar(ch);
    60         ch = getchar();
    61     }
    62     return 0;
    63 }
    View Code

    ——written by Lyon

  • 相关阅读:
    XML WebService完全实例详细解析
    List (Java 2 Platform SE 5.0)
    frameset
    关于在outlook2007里面编辑签名的问题
    关于javax.servlet.Http.*;不能被引用的问题
    select标签HTML,刚做地。
    UIButton中setTitleEdgeInsets和setImageEdgeInsets的使用
    玩转UICollectionViewLayout
    常用公共方法
    cell嵌套UIWebView遇到的几个问题
  • 原文地址:https://www.cnblogs.com/LyonLys/p/hdu_1736_Lyon.html
Copyright © 2011-2022 走看看