-6
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
int main() {
ios_base::sync_with_stdio(false);cin.tie(NULL);
string line;
int acc = 0;
while (cin >> line) {
if (line == "caw") {
cin >> line;
cout << acc << endl;
acc = 0;
} else {
int val = 0;
for (int i = 0; i < 3; ++i) {
val <<= 1;
val += line[i] == '*';
}
acc += val;
}
}
return 0;
}
我碰到這個解決方案來URI 1848年解決方案
誰能請解釋一下這是否VAL + =行[I] == 「*」;手段?
請幫忙!!!!
'#define endl'\ n'','using namespace std;'o.O ??? –
首先,不要盲目複製粘貼或以其他方式使用您在互聯網上找到的來源,而不是不知道自己做了什麼。其次,這是一個糟糕的程序,並且包含''是一個明確的指示器(參見[爲什麼不應該包含?](http:// stackoverflow。 com/questions/31816095/why-should-i-not-include-bits-stdc-h)以獲得更多信息)。第三,這個程序真的很糟糕,因爲它使用了一個宏'endl',它恰好與'std :: endl'相同,它打印一個換行符並刷新輸出。 –
@Someprogrammerdude:從技術上講,由於這種重新定義,程序行爲是* undefined *。 – Bathsheba