zoukankan      html  css  js  c++  java
  • 在QT程序中使用cout和cin

    1先输入10个数字,再输出。


      1. #include <QtCore/QCoreApplication>  
      2. #include <QtCore/QList>  
      3. #include <QTextStream>  
      4. int main(int argc, char *argv[])  
      5. {  
      6.     QCoreApplication app(argc, argv);  
      7.     QTextStream cin(stdin, QIODevice::ReadOnly);   
      8.     QTextStream cout(stdout, QIODevice::WriteOnly);    
      9.     QList<int> list;  
      10.     cout << "Please enter ten numbers: ";  
      11.     //注意,此时的cout是不会在输入之遥自动刷新缓冲区的  
      12.     cout.flush();  
      13.     for(int i=0; i<10; i++)  
      14.     {  
      15.         int temp;  
      16.         cin >> temp;  
      17.         list.push_back(temp);  
      18.     }  
      19.     QList<int>::iterator iter;  
      20.     for(iter=list.begin();iter!=list.end();iter++)  
      21.         cout << *iter << " ";  
      22.     cout << endl;  
      23.     return 0;  
      24. }  

    http://blog.csdn.net/small_qch/article/details/6621757

  • 相关阅读:
    Max Sum Plus Plus HDU
    Monkey and Banana HDU
    Ignatius and the Princess IV HDU
    Extended Traffic LightOJ
    Tram POJ
    Common Subsequence HDU
    最大连续子序列 HDU
    Max Sum HDU
    畅通工程再续
    River Hopscotch POJ
  • 原文地址:https://www.cnblogs.com/findumars/p/4851473.html
Copyright © 2011-2022 走看看