cout << "请输入x的值" << endl;
while (cin >> t1) {
x.push_back(t1);
}
cout << "请输入y的值" << endl;
while (cin >> t2){
y.push_back(t2);
}
cout << "请输入r的值" << endl;
cin >> r;
`
逻辑上感觉没错呀,但就是会跳过t2和r的输入。。。。
why?
C++新手,求大佬们帮一下。怎样才能连续输入?
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
3条回答 默认 最新
- threenewbee 2018-10-21 13:41关注
#include <iostream> #include <vector> using namespace std; int main() { int t1, t2, r; vector<int> x, y; cout << "请输入x的值" << endl; while (cin >> t1, t1) { x.push_back(t1); } cout << "请输入y的值" << endl; while (cin >> t2, t2){ y.push_back(t2); } cout << "请输入r的值" << endl; cin >> r; for (int i = 0; i < y.size(); i++) cout << y[i] << " "; cout << "\nr=" << r << endl; return 0; }
如果问题得到解决,麻烦点下我回答右边的采纳,谢谢
解决 1无用