-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