zoukankan      html  css  js  c++  java
  • pat乙级1052

    输出“”字符:

    1 cout << "\";

    因为‘’是转义字符,例如“ ”代表换行。

    同理,printf输出“%”:

    1 printf("%%");
     1 #include <iostream>
     2 #include <string>
     3 using namespace std;
     4 
     5 void func(string s, string arr[])
     6 {
     7     int t = 0;
     8     for (int i = 0; i < s.size(); i++)
     9     {
    10         if (s[i] == '[')
    11         {
    12             i++;
    13             while (s[i] != ']')
    14             {
    15                 arr[t] += s[i];
    16                 i++;
    17             }
    18             t++;
    19         }
    20     }
    21 }
    22 bool func2(string &s, int i, string arr[])
    23 {
    24     if (i >= 10 || arr[i].empty())
    25     {
    26         cout << "Are you kidding me? @\/@" << endl;
    27         return false;
    28     }
    29     s += arr[i];
    30     return true;
    31 }
    32 int main()
    33 {
    34     string hands, eyes, mouths;
    35     getline(cin, hands);
    36     getline(cin, eyes);
    37     getline(cin, mouths);
    38     string hands2[10], eyes2[10], mouths2[10];
    39     func(hands, hands2);
    40     func(eyes, eyes2);
    41     func(mouths, mouths2);
    42     
    43     int n;
    44     cin >> n;
    45     int h1, e1, m, e2, h2;
    46     for (int i = 0; i < n; i++)
    47     {
    48         string s;
    49         cin >> h1 >> e1 >> m >> e2 >> h2;
    50         if (!func2(s, h1-1, hands2)) continue;
    51         s += "(";
    52         if (!func2(s, e1-1, eyes2)) continue;
    53         if (!func2(s, m-1, mouths2)) continue;
    54         if (!func2(s, e2-1, eyes2)) continue;
    55         s += ")";
    56         if (!func2(s, h2-1, hands2)) continue;
    57         cout << s << endl;
    58     }
    59     return 0;
    60 }
  • 相关阅读:
    python的logging库
    python的os库
    python的setup和teardown
    CF339D Xenia and Bit Operations线段树
    poj3311Hie with the Pie状压dp
    poj3254Corn Fields状压Dp
    CF414BMashmokh and ACMDP
    母函数6连杀
    母函数hdu1085
    UVA 1401Remember the WordDp
  • 原文地址:https://www.cnblogs.com/lxc1910/p/8574574.html
Copyright © 2011-2022 走看看