变长数组
来源:互联网 发布:exshop建站 编辑:程序博客网 时间:2024/04/28 04:38
使用new分配变长数组
#include <iostream.h>
void main()
{
int len;
cout << "请输入数组的长度: ";
cin >> len;
int *array=new int[len];
cout << "数组的长度是" << len << endl;
//................
delete[] array;
return;
}
void main()
{
int len;
cout << "请输入数组的长度: ";
cin >> len;
int *array=new int[len];
cout << "数组的长度是" << len << endl;
//................
delete[] array;
return;
}
---------------------------------------------------
使用vector分配变长数组
#include <iostream>
#include <vector>
using namespace std;
void main()
{
int len;
cout << "请输入数组的长度: ";
cin >> len;
vector <int> array(len);//声明变长数组
for(int i=0;i <len;i++)
{
array[i]=i;
cout <<array[i] << "/t ";
}
return;
}
#include <vector>
using namespace std;
void main()
{
int len;
cout << "请输入数组的长度: ";
cin >> len;
vector <int> array(len);//声明变长数组
for(int i=0;i <len;i++)
{
array[i]=i;
cout <<array[i] << "/t ";
}
return;
}
- 变长数组
- 变长数组
- 变长数组
- 变长数组
- 变长数组
- 变长数组
- 变长数组
- 变长数组
- 变长数组
- 变长数组
- 变长数组
- 变长数组
- C语言变长数组
- 变长数组和alloca
- PL/SQL变长数组
- C语言变长数组
- 变长(柔性)数组
- PL/SQL变长数组
- java除法保留小数问题
- 诗歌 一支小雨伞
- PL/SQL优化规则小结
- 汇编学习 NO6
- 网络的划分
- 变长数组
- CXF之用spring配置客户端实例(1)
- POJ_1050(最大子矩阵和)
- Quick Search Box for Windows 停止开发,如何单独安装之?
- 昨天去exoweb的复试感受,及其中一题的部分仅供看下的答案
- 记录记录
- 定制CentOS光盘
- asp.net如何去掉HTML标记
- The Predator-Prey Equation in Matlab