在线性表中给n个元素赋值
IDE是VS2013
#include "stdafx.h"
#include<list>
#include<iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
list<int> l;
int i=0,temp,amount;
cin >> amount;//输入线性表元素个数
/*for (i=0; i<5; i++)
{
cin >> temp;
l.push_back(temp);
}*/
while (i < amount)
{
cin >> temp;
l.push_back(temp);
i++;
}
l.sort();//线性表排序
for (auto p : l)//输出
{
cout << p << ' ';
}
cout << endl;
system("pause");
return 0;
}