有些东西已经变得很含糊了。。譬如说你后来给的样例wohd 25 dosh 89 2003424 25 89 dils34 sh 25 25 8就算是人去读都不能读懂这是什么意思。这样根本没有办法去设计算法。你能不能为你所遇到的实际输入做一个详细的说明?现在这样不是不能做,而是不明白你的意思。。============================#include #include using namespace std;int main() {
freopen("abc.txt", "r", stdin);
string buf;
int ans = 0;
while(getline(cin, buf)) {
char A[20], B[20], C[20];
sscanf(buf.c_str(), "%s%s%s", A, B, C);
if(0 == strcmp(B, "25")) {
ans += C[strlen(C)-1] == '*' ? 2 : 1;
}
}
cout << "总数为:" << ans << endl;
while(1);} |