Skip to content

Commit fc9813a

Browse files
committed
boj 5355 화성 수학
1 parent 262cac1 commit fc9813a

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

문자열 처리/5355.cpp

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#include <iostream>
2+
#include <string>
3+
using namespace std;
4+
5+
string str;
6+
7+
void func() {
8+
string tmp = "";
9+
double x = -1.0;
10+
for (auto s : str) {
11+
if (s == '@') x *= 3.0;
12+
else if (s == '%') x += 5.0;
13+
else if (s == '#') x -= 7.0;
14+
else if (s == ' ') {
15+
if (x < 0) x = stod(tmp);
16+
}
17+
else tmp += s;
18+
}
19+
20+
cout << fixed; cout.precision(2);
21+
cout << x << '\n';
22+
}
23+
24+
void input() {
25+
getline(cin, str);
26+
}
27+
28+
int main() {
29+
cin.tie(NULL); cout.tie(NULL);
30+
ios::sync_with_stdio(false);
31+
32+
string s;
33+
int tc;
34+
getline(cin, s);
35+
tc = stoi(s);
36+
while (tc--) {
37+
input();
38+
func();
39+
}
40+
41+
return 0;
42+
}

0 commit comments

Comments
 (0)