1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | #include <iostream> #include <string> #include <algorithm> using namespace std; int main() { string N; int n; getline(cin, N); n = stoi(N); string s; float first; float *result = new float[n]; for (int i = 0; i<n; i++){ getline(cin, s); first = stof(s); s = s.substr(2, s.size() - 1); s.erase(remove(s.begin(), s.end(), ' '), s.end()); for (int j = 0; j<s.size(); j++){ if (s[j] == '@') first *= 3; if (s[j] == '%') first += 5; if (s[j] == '#') first -= 7; } result[i] = first; } for (int j = 0; j<n; j++){ printf("%.2f\n", result[j]); } return 0; } | cs |
'Algorithm > BOJ 기초' 카테고리의 다른 글
[백준] 수들의합 1789 Python C++ (0) | 2019.10.02 |
---|---|
[백준] 소인수분해 11653 Python C++ (0) | 2019.10.02 |
[백준] 문자열 반복 2675 C++ (0) | 2019.10.02 |
[백준] 스택수열 1874 Python (0) | 2019.09.28 |
[백준] 2839 설탕문제 Java (0) | 2019.04.13 |