国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C++ > 正文

c++創建二維動態數組與內存釋放問題

2020-01-26 13:41:41
字體:
來源:轉載
供稿:網友

如下:

#include <iostream>#include <windows.h>using namespace std;int main(){  cout << "create dynamic two-dimension array..." << endl;  int sizeX = 5;  int sizeY = 8;  // 申請  double** array = new double*[sizeX];  for (int i = 0; i < sizeX; i++) {    array[i] = new double[sizeY];  }  for (int i = 0; i < sizeX; i++) {    for (int j = 0; j < sizeY; j++) {      array[i][j] = i + j;    }  }   for (int i = 0; i < sizeX; i++) {    for (int j = 0; j < sizeY; j++) {      cout << array[i][j];    }    cout << endl;  }  // 釋放  for (int i = 0; i < sizeX; i++) {      delete[] array[i];  }  delete[] array;  system("pause");  return 0;}

如上,結果如下:

create dynamic two-dimension array...
01234567
12345678
23456789
345678910
4567891011
Press any key to continue . . .

總結

以上所述是小編給大家介紹的c++創建二維動態數組與內存釋放問題,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對武林網網站的支持!

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 涪陵区| 潜江市| 彰武县| 蓝山县| 神农架林区| 吉木萨尔县| 武义县| 张掖市| 浮山县| 永吉县| 财经| 太白县| 泊头市| 察哈| 张家界市| 乐至县| 文成县| 城市| 琼海市| 临漳县| 颍上县| 宣城市| 咸宁市| 抚远县| 云浮市| 五家渠市| 武冈市| 云阳县| 深水埗区| 安平县| 丁青县| 宜川县| 湛江市| 通州区| 萨迦县| 福清市| 静安区| 泰宁县| 赤峰市| 吉水县| 福清市|