#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <vector>
using namespace std;
int main()
{
vector <int>a;
vector <int>b(100);
vector <int>c(100,1);
a.push_back(1);
a.push_back(2);
a.push_back(3);
for (auto& ele : a)
{
cout << ele << endl;
}
cout << a.size()<<endl;
if (a.empty())
cout << "空" << endl ;
else
cout << "非空" << endl;;
a.pop_back();
a.pop_back();
for (auto& ele : a)//&不要也可以
cout << ele << endl;
cout << a.size()<<endl;
a.clear();
for (auto& ele : a)
{
cout << ele << endl;
}
if (a.empty())
cout << "空";
else
cout << "非空";
cout << a.size() << endl;
return 0;
}
容器初学(更新)
最新推荐文章于 2024-08-25 06:11:42 发布