accelerated-c++

Why are some strings cutoff when attempting to read a mixture of numeric and non-numeric input as in the following code?

☆樱花仙子☆ 提交于 2019-12-11 01:57:26
问题 Program: #include <iostream> #include <string> using std::cin; using std::cout; using std::endl; using std::string; int main(){ double x; string name; while(cin >> name){ cout<<name<<endl; while (cin >> x); cin.clear(); } } Input: Moo 100 100 100 100 100 100 100 100 Moore 75 85 77 59 0 85 75 89 Norman 57 78 73 66 78 70 88 89 Westerly 43 98 96 79 100 82 97 96 Edwards 77 72 73 80 90 93 75 90 Franklin 47 70 82 73 50 87 73 71 Jones 77 82 83 50 10 88 65 80 Carpenter 47 90 92 73 100 87 93 91 Output