|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
代码如下, 死循环了, 想知道用 sscanf 需要注意的一些事, 每次都是类型不同报错, 很烦, 求助
- #include <bits/stdc++.h>
- using namespace std;
- string t;
- int a, b, c, d, e;
- int main(){
- ios::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- getline(cin, t);
- while(sscanf(t.c_str(), "%d.%d.%d.%d:%d;", &a, &b, &c, &d, &e) == 5){
- cout << a << b << c << d << e << endl;
- }
- return 0;
- }
复制代码
那个语句就是把 cin cout 速度提上来
怎么个提法?原理?参考文档?
- #include <bits/stdc++.h>
- using namespace std;
- string t;
- int a, b, c, d, e;
- int main(){
- ios::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- getline(cin, t);
- int offset = 0, n;
- while(sscanf(t.c_str() + offset, "%d.%d.%d.%d:%d;%n", &a, &b, &c, &d, &e, &n) == 5){
- cout << a << b << c << d << e << endl;
- offset += n;
- }
- return 0;
- }
复制代码
|
|