#include <iostream>
#include <string>
#include <vector>
#include <cctype>
int main()
{
    using std::cin;
    using std::cout;
    using std::endl;
    using std::string;
    using std::vector;
  string s1;
    vector<int> ivec;
    int a;
    while(cin >> a)
        ivec.push_back(a);
    if(ivec.size()%2==0)
        for(vector<int>::size_type j=0;j!=ivec.size();j+=2)
            cout << ivec[j]+ivec[j+1] << "  ";
    else if(ivec.size()%2==1)
    {
        cout << "Please enter the last number: ";
        cin >> a; //就是在这里,为什么运行的时候就是不读数据,直接跳到下一行把这个a就推进去了?
        ivec.push_back(a);
        for(vector<int>::size_type j=0;j!=ivec.size();j+=2)
        cout << ivec[j]+ivec[j+1] << "  ";
    }    
    return 0;    
}
我的头文件多写了。。。因为在看书,所以不高兴每次筛选需要的头文件。。。
谢谢!
[此贴子已经被作者于2007-7-6 14:00:30编辑过]



 
											





 
	    

 
	




