2017.11.09 李锦浩【第30天】
今天对结构进行初步的学习,对其中的部分概念有了了解,但对具体操作还需要进一步的学习。另外今天编写了一个随机数组的测试程序,运用了动态数组,熟悉了一下。
附:随机数组测试:
#include <iostream>
#include<ctime>
using namespace std;
void A(int *&pa, int len)//分配动态数组;
{
pa = new int[len];
if (pa == NULL)
{
cout << "allocation faiure\n";//检查是否申请到动态空间;
return;
}
for (int i = 0; i < len; i++)
pa[i] = 0;
}
int main()
{
int *B = NULL;
int n;
cout << "请选择数组长度\n";
cin >> n;
A(B, n);
srand(time(0));
for (int i = 0; i < n; i++)
{
B[i] = rand() % 100;
}
for (int i = 0; i < n; i++)
cout << B[i] << " ";
cout << endl;
for (int i = 0; i < (n/2); i++)
{
int temp;
temp = B[i];
B[i] = B[n - i - 1];
B[n - i - 1] = temp;
}
for (int i = 0; i < n; i++)
cout << B[i] << " ";
system("pause");
return 0;
}
明日任务:复习前面学习的内容,继续学习集合部分。