ch8_7.cpp
资源名称:c.rar [点击查看]
上传用户:puke2000
上传日期:2022-07-25
资源大小:912k
文件大小:0k
源码类别:

C#编程

开发平台:

Visual C++

  1. //*********************
  2. //**    ch8_7.cpp    **
  3. //*********************
  4. #include <iostream.h>
  5. #include <alloc.h>
  6. void main()
  7. {
  8.   int arraysize;    //元素个数
  9.   int *array;
  10.   cout <<"please input a number of array:n";
  11.   cin >>arraysize;
  12.   array =(int*)malloc(arraysize*sizeof(int));      //堆内存分配
  13.   for(int count=0; count<arraysize; count++)
  14.     array[count]=count*2;
  15.   for(int count=0; count<arraysize; count++)
  16.     cout <<array[count] <<"    ";
  17.   cout <<endl;
  18. }