一道C++程序

[复制链接]
查看11 | 回复0 | 2009-9-6 23:36:08 | 显示全部楼层 |阅读模式
有些东西已经变得很含糊了。。譬如说你后来给的样例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);}
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行