基本信息
源码名称:动态数组底层实现(入门级)
源码大小:0.09M
文件格式:.zip
开发语言:C/C++
更新时间:2020-04-19
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
c 数组的基本操作
c 数组的基本操作
//2020-3-26
//yyz
#include <iostream>
#include "Array.h"
#include "Student.h"
void demo1();
void demo2();
using namespace std;
int main()
{
demo1();
return 0;
}
void demo2()
{
Array<Student> arr = Array<Student>(20);
arr.addLast(Student("Alice",100));
arr.addLast(Student("Bob",66));
arr.addLast(Student("Ming",88));
arr.print();
}
void demo1()
{
Array<int> arr1 = Array<int>();
/*int a = arr1.getSize();
int b = arr1.getCapacity();
cout<< a << " "<< b <<endl;*/
for (int i = 0; i < 10; i)
{
arr1.addLast(i);
}
arr1.print();
arr1.addFirst(-1);
arr1.print();
arr1.addLast(100);
arr1.print();
arr1.add(3,0);
arr1.print();
/* a = arr1.getSize();
b = arr1.getCapacity();
cout<< a << " "<< b <<endl;*/
arr1.print();
cout<< "arr1[12]= " <<arr1.get(12)<<endl;
arr1.set(0,999);
arr1.print();
arr1.removeLast();
arr1.print();
arr1.remove(5);
arr1.print();
arr1.removeFirst();
arr1.print();
/* int arr[10];
for (int i = 0; i < 10; i) {
arr[i]=i;
}
for (int j = 0; j < 10; j) {
cout << arr[j] << " ";
}
cout << endl;
int scores[] = {100, 99, 66};
for (int k = 0; k < sizeof(scores) / sizeof(scores[0]); k) {
cout << scores[k] << " ";
}
cout << endl;
//在socre中遍历,类似java以及Python中遍历方法
for (int score : scores) {
cout << score << " ";
}
cout << endl;
scores[0] = 98;
for (int l = 0; l < sizeof(scores) / sizeof(scores[0]); l) {
cout << scores[l] << " ";
}
cout << endl;
*/
}