6.3w+
社区成员
#include "stdafx.h"
#include <iostream>
#include <vector>//采用vector容器就可以了,
int main()
{
typedef std::vector<int> Ive;
Ive v;
int c;
std::cout<<"输入一串整数:"<<std::endl;
while(std::cin>>c)
{
v.push_back(c);
}
Ive::iterator it=v.begin();
while(it!=v.end())
{
std::cout<<*it<<std::endl;
++it;
}
return 1;
}
char ch;
while(cin>>ch)
#include <iostream>
#include <vector>
using namespace std;
int main()
{
vector<int> vi;
int n;
while(true){//反复读取每一个整数
while(cin.peek()==' '||cin.peek()=='\t') cin.ignore();//跳过空格和制表符
if(cin.peek()=='\n') break;//如果遇到换行符就结束
cin >> n;//不是换行符就读入一个整数
vi.push_back(n);//加入到容器中
}
//使用容器中的数据……
return 0;
}