-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweb.cpp
More file actions
28 lines (27 loc) · 753 Bytes
/
web.cpp
File metadata and controls
28 lines (27 loc) · 753 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/* Cấp phát mảng động */
#include <iostream>
using namespace std;
int main()
{
const int SIZE = 5; int * pArray; pArray = new int[SIZE];
// Cấp phát mảng động thông qua toán tử new[]
// Gán mỗi phần tử của mảng với một số ngẫu nhiên nằm trong khoảng 1 và 100
for (int i = 0; i < SIZE; ++i)
{ *(pArray + i) = rand() % 100; }
// In ra mảng
for (int i = 0; i < SIZE; ++i)
{ cout << *(pArray + i) << " "; }
cout << endl;
delete[] pArray;
// Giải phóng vùng nhớ thông qua toán tử new[]
return 0;
}
/*
int **a=new int*[n]; // cấp phát mảng 2 chiều
for (int i=0;i<n;i++)
for (int j=0;j<m,j++)
{
cin>>a[i][j];
a[i]=*(a+i);
a[i][j]=*(a[i]+j)=*(*(a+i)+j);
} */