# 25. 天气猜猜看

if(order == "DOWN")
temper -= 0.1;
else
temper += 0.1;


#include <iostream>
#include <string>
using namespace std;
int main(){
double temper;int __;string order;
cin >> temper;cin >> __;cin >> order;
for (int _ = 0; _ < __; _++){
string next_order;
if (cin >> next_order){
if (next_order == order){
if(order == "DOWN")
temper -= 0.1;
else
temper += 0.1;
}
else{
if(next_order == "DOWN")
temper = 30.0;
else
temper = 0.0;
}
order = next_order;
}
else{
if(order == "DOWN")
temper -= 0.1;
else
temper += 0.1;
}
printf("%.1lf\n",temper);
}
}


PS：涉及到浮点数输出的时候cout是真滴麻烦，这题如果用cout输出长这个样子cout << fixed << setprecision(1) << temper << endl;

1. 调整步长；
2. 输出

#include <iostream>
#include <string>
using namespace std;

int t, n;
int variation[1001];

inline bool overflow(int res) noexcept { return res < 0 || res > 300; }

void solve() {
int res = t;
for (int i = 0; i < n; ++i) {
res += variation[i];
if (overflow(res)) {
if (res < 0) {
// need up-compensation;
int j = i - 1;
for (; variation[j] < 0; --j)
;
++variation[j];
res = 0;
} else {
// needs down-compensation;
int j = i - 1;
for (; variation[j] > 0; --j)
;
--variation[j];
res = 300;
}
}
}

// #2 Output;
res = t;
for (int i = 0; i < n; ++i) {
res += variation[i];
printf("%d.%d\n", res / 10, res % 10);
}
}

int main() {
double temp;
cin >> temp >> n;
t = temp * 10;
for (int i = 0; i < n; ++i) {
string a;
cin >> a;
variation[i] = a == "UP" ? 1 : -1;
}
solve();
}