利用vector或者list
比如以下,运用list
list<int> p;
int n=0;
//构造链表
int b;
while(cin>>b)
{
p.push_back(b);
n++;
if (cin.get() == '\n')
break;
}
或者是利用 vector
int n=0;
vector<int> a;
int b;
while(cin>>b)
{
a.push_back(b);
n++;
if (cin.get() == '\n')
break;
}