UVA 272 TEX Quotes 题解

//刚看刘汝佳的第二版紫书 1 #include <iostream>
 2 #include <cstdio>
 3 #include <cstring>
 4 #include <cstdlib>
 5 #include <cmath>
 6 #include <algorithm>
 7 #include <set>
 8 #include <map>
 9 #include <string>
10 #include <queue>
11 #include <stack>
12 #include <vector>
13 #include <fstream>
14 #include <cctype>
15 #define fi for (int i = 1; i <= n; ++i)
16 #define fj for (int j = 1; j <= m; ++j)
17 #define INF 0x3fffffff
18 #define pau system("pause")
19 #define printcolck printf("Time used = %.2fs\n", (double) clock() / CLOCKS_PER_SEC);
20 #define eps 1e-5
21 #define cin std::cin
22 #define cout std::cout
23 #define endl std::endl
24
25 const double pi = acos(-1.0);
26 const int max_n = 1e5 + 5;
27 typedef long long ll;
28 typedef std::pair<int, int> pii;
29
30 template<class Q> void getint(Q &res, char ch = getchar()) {
31     while (!isdigit(ch) && ch != ‘-‘)    ch = getchar();
32     bool flag = true;
33     if (‘-‘ == ch)  flag = false, ch = getchar();
34     for (res = 0; isdigit(ch); ch = getchar())  res = res * 10 + ch - 48;
35     if (!flag)  res = -res;
36 }
37 void putint(int x) {
38     int i = 0, a[10];
39     bool flag = true;
40     if (x < 0) {
41         flag = false;
42         x = -x;
43     } else if (x == 0) {
44         a[i++] = 0;
45     }
46     while (x > 0) {
47         a[i++] = x % 10;
48         x /= 10;
49     }
50     if (flag == false)  putchar(‘-‘);
51     for (int j = i - 1; j >= 0; --j)    putchar(a[i] + 48);
52 }
53 int mmax(int a, int b)  {return a > b ? a : b;}
54 int mmin(int a, int b)  {return a < b ? a : b;}
55 int gcd(int a, int b)   {while (b) {b ^= a ^= b ^= a %= b;} return a;}
56
57 /*int parent[max_n], rank[max_n];
58 void ini() {
59     for (int i = 1; i < 10001; ++i) {
60         parent[i] = i;
61         rank[i] = 0;
62     }
63 }
64 int find(int x) {
65     return x == parent[x] ? x : parent[x] = find(parent[x]);
66 }
67 void unite(int x, int y) {
68     x = find(x);
69     y = find(y);
70     if (x == y) return;
71
72     if (rank[x] < rank[y]) {
73         parent[x] = y;
74     } else {
75         parent[y] = x;
76         if (rank[x] == rank[y]) rank[x]++;
77     }
78 }*/
79
80 //#define LOCAL
81
82 int main() {
83 #ifdef LOCAL
84     freopen("data.in", "r", stdin);
85     freopen("data.out", "w", stdout);
86 #endif // LOCAL
87     char c;
88     int t = 1;
89     while ((c = getchar()) != EOF) {
90         if (‘"‘ == c) {
91             if (t)  printf("``");
92             else    printf("‘‘");
93             t = !t;
94         } else {
95             putchar(c);
96         }
97     }
98     return 0;
99 }
时间: 2024-10-08 13:14:17

UVA 272 TEX Quotes 题解的相关文章

UVa 272 Tex Quotes --- 水题

题目大意:在TeX中,左引号是 ``,右引号是 ''.输入一篇包含双引号的文章,你的任务是把他转成TeX的格式 解题思路:水题,定义一个变量标记是左引号还是右引号即可 /* UVa 272 Tex Quotes --- 水题 */ #include <cstdio> #include <cstring> int main() { #ifdef _LOCAL freopen("D:\\input.txt", "r", stdin); #endi

UVa 272——TeX Quotes

TeX Quotes Time limit: 3.000 seconds TeX is a typesetting language developed by Donald Knuth. It takes source text together with a few typesetting instructions and produces, one hopes, a beautiful document. Beautiful documents use `` and " to delimit

UVA 272 - TEX Quotes

题意:将给定字符串中的双引号改为规定格式,左右修改不同 分析:字符串中有空格,插入的引号必须用字符串表示,所有采用逐个字符串处理 注释:水题 1 //#define LOCAL 2 #include"iostream" 3 #include"cstdio" 4 using namespace std; 5 int main() 6 { 7 #ifdef LOCAL 8 freopen("input.txt","r",stdin

272 TEX Quotes

#include<stdio.h>int main(){ char a; int b=1; while((a=getchar())!=EOF) { if(a=='"'&&b==1) { printf("``"); b=0; } else if(a=='"'&&b==0) { printf("''"); b=1; } if(a!='"') { printf("%c",a);

【UVA272】TEX Quotes

A - TEX Quotes Time Limit:3000MS    Memory Limit:0KB    64bit IO Format:%lld & %llu SubmitStatusPracticeUVA 272 Appoint description: Description TeX is a typesetting language developed by Donald Knuth. It takes source text together with a few typeset

TEX Quotes(字符串,水)

TEX Quotes Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 9674   Accepted: 5073 Description TEX is a typesetting language developed by Donald Knuth. It takes source text together with a few typesetting instructions and produces, one hop

UVa272 Tex Quotes

TeX Quotes TeX is a typesetting language developed by Donald Knuth. It takes source text together with a few typesetting instructions and produces, one hopes, a beautiful document. Beautiful documents use `` and " to delimit quotations, rather than t

POJ 1488 Tex Quotes --- 水题

POJ 1488 题目大意:给定一篇文章,将它的左引号转成 ``(1的左边),右引号转成 ''(两个 ' ) 解题思路:水题,设置一个bool变量标记是左引号还是右引号即可 /* POJ 1488 Tex Quotes --- 水题 */ #include <cstdio> #include <cstring> int main() { #ifdef _LOCAL freopen("D:\\input.txt", "r", stdin); #

POJ - 1488 - TEX Quotes (字符串!)

TEX Quotes Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 9046   Accepted: 4743 Description TEX is a typesetting language developed by Donald Knuth. It takes source text together with a few typesetting instructions and produces, one hop