@Moritz
2019-01-31T07:38:54.000000Z
字数 647
阅读 949
C++primer练习 C++ 编程 所有文稿
string into listWrite a program to read a sequence of strings from the standard input into a list. Use iterators to write a loop to print theelements in the list. List the changes you needed to make if rewriting the program from 9.18 where strings are to input into a deque.
list<char> s;list<char>::iterator it=s.end();char c;while(c=getchar()){if (c==10) break;else it=s.insert(it,c);}for(auto i=s.rbegin();i!=s.rend();i++)cout<<*i;cout<<endl;return 0;
When I first wrote this program, I didn't use reverse_iterator. I fount that +1, -1 and >= can't be used.
for(auto i=s.end()-1;i<=s.begin();i--)//error,program can't be compiledcout<<*i;
2019.1.30
