problemscpp
A collection of my answers to algorithm problems in c++.
静态 Public 成员函数 | 所有成员列表
luogu::P1553类 参考

洛谷 P1553 数字反转(升级版) 更多...

#include <luogu.h>

静态 Public 成员函数

static int main (istream &cin, ostream &cout)
 

详细描述

洛谷 P1553 数字反转(升级版)

在文件 luogu.h561 行定义.

成员函数说明

◆ main()

int luogu::P1553::main ( istream &  cin,
ostream &  cout 
)
static

在文件 luogu.cpp2068 行定义.

2068 {
2069 deque<char> dq[2];
2070 stringstream ss[2];
2071 int current = 0;
2072 int limit = 1;
2073 char op = 'N';
2074 char ch;
2075 while(cin >> ch) {
2076 if(isdigit(ch) != 0) {
2077 bool flag = false;
2078 dq[current].push_front(ch);
2079 } else {
2080 op = ch;
2081 current++;
2082 }
2083 }
2084 if(op == '.' || op == '/') {
2085 limit = 2;
2086 }
2087 for(int i = 0; i < limit; i++) {
2088 while(dq[i].size() > 1 && dq[i].front() == '0') {
2089 dq[i].pop_front();
2090 }
2091 if(op == '.' && i == 1) {
2092 while(dq[i].size() > 1 && dq[i].back() == '0') {
2093 dq[i].pop_back();
2094 }
2095 }
2096 while(!dq[i].empty()) {
2097 ss[i] << dq[i].front();
2098 dq[i].pop_front();
2099 }
2100 }
2101 cout << ss[0].str();
2102 if(op != 'N') {
2103 cout << op;
2104 if(op != '%') {
2105 cout << ss[1].str();
2106 }
2107 }
2108 return 0;
2109 }

被这些函数引用 luogu::TEST().


该类的文档由以下文件生成: