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

动态创建整形数组

Posted on 2011-05-27 21:52 Kevin_Zhang 阅读(428) 评论(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;
}


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理