#33698: 請問最後10%


justin.sw.yang@gmail.com (VV_|三_I)

學校 : 新北市立新店高級中學
編號 : 159485
來源 : [223.141.121.129]
最後登入時間 :
2024-04-08 17:28:01
g005. 倒置文章 (Inversion) -- TOI練習賽202105新手組第2題 | From: [118.160.100.165] | 發表日期 : 2023-01-24 15:01

//最後10%應該和測資一樣吧?

#include <bits/stdc++.h>
using namespace std;

int main() {

bool ok = 0;
string s, tmp;
cin >> s;
for (char i : s) {
if (i == '+') {
int len = tmp.length();
if (len != 0) {
for (int i = len-1; i >= 0; --i) {
cout << tmp[i];
}
ok = 0;
tmp.clear();
}
else {
ok = 0;
}
}
else if (i == '-') {
int len = tmp.length();
if (len != 0) {
for (int i = len-1; i >= 0; --i) {
cout << tmp[i];
}
tmp.clear();
}
ok = 1;
}
else {
if (ok == 1) {
tmp += i;
}
else {
cout << i;
}
}
}
if (tmp.length() != 0) {
for (int i = tmp.length(); i >= 0; --i) {
cout << tmp[i];
}
}
return 0;
}
 
#33699: Re: 請問最後10%


cges30901 (cges30901)

學校 : 不指定學校
編號 : 30877
來源 : [101.136.203.77]
最後登入時間 :
2024-04-07 15:34:14
g005. 倒置文章 (Inversion) -- TOI練習賽202105新手組第2題 | From: [27.53.33.47] | 發表日期 : 2023-01-24 16:58

for (int i = tmp.length(); i >= 0; --i) {


i = tmp.length()-1

 
#33717: Re: 請問最後10%


justin.sw.yang@gmail.com (VV_|三_I)

學校 : 新北市立新店高級中學
編號 : 159485
來源 : [223.141.121.129]
最後登入時間 :
2024-04-08 17:28:01
g005. 倒置文章 (Inversion) -- TOI練習賽202105新手組第2題 | From: [118.160.78.158] | 發表日期 : 2023-01-25 19:05

for (int i = tmp.length(); i >= 0; --i) {


i = tmp.length()-1

感謝~~

 
ZeroJudge Forum