C++博客 :: 首页 :: 新随笔 ::  ::  :: 管理

日历

<2025年4月>
303112345
6789101112
13141516171819
20212223242526
27282930123
45678910

程序的灵魂--算法

沙场秋点兵,壮士凯歌还

他山之石,可以攻玉

围观强人

搜索

  •  

最新评论

动态创建整形数组

Posted on 2011-05-27 21:52 Kevin_Zhang 阅读(442) 评论(0)  编辑 收藏 引用 所属分类: C/C++
// test3.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include 
"iostream"
using namespace std;


int main(int argc, char* argv[])
{   
    
int length,i,* ptr1;
    cout
<<"请输入数组的长度:";
    cin
>>length;
    ptr1
=new int[length];
    
for(i=0;i<length;i++)
        
*(ptr1+i)=i*10;
    
for(i=0;i<length;i++)
        cout
<<ptr1[i]<<" ";
    cout
<<endl;
    delete[] ptr1;
    
return 0;
}