1先输入10个数字,再输出。
- #include <QtCore/QCoreApplication>
- #include <QtCore/QList>
- #include <QTextStream>
- int main(int argc, char *argv[])
- {
- QCoreApplication app(argc, argv);
- QTextStream cin(stdin, QIODevice::ReadOnly);
- QTextStream cout(stdout, QIODevice::WriteOnly);
- QList<int> list;
- cout << "Please enter ten numbers: ";
- //注意,此时的cout是不会在输入之遥自动刷新缓冲区的
- cout.flush();
- for(int i=0; i<10; i++)
- {
- int temp;
- cin >> temp;
- list.push_back(temp);
- }
- QList<int>::iterator iter;
- for(iter=list.begin();iter!=list.end();iter++)
- cout << *iter << " ";
- cout << endl;
- return 0;
- }
http://blog.csdn.net/small_qch/article/details/6621757