We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 262cac1 commit fc9813aCopy full SHA for fc9813a
문자열 처리/5355.cpp
@@ -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