标题:这代码为什么错了啊
取消只看楼主
草狼
Rank: 9Rank: 9Rank: 9
等 级:蜘蛛侠
威 望:2
帖 子:577
专家分:1040
注 册:2010-4-6
结帖率:94.44%
已结贴  问题点数:20 回复次数:1 
这代码为什么错了啊
#include<iostream>
using namespace std;
void APP(int *pa,int n);
int main()
{
    int *ary=NULL,*t;
    int i,n;
    cout<<"n=";
    cin>>n;
    APP(ary,n);
    for(t=ary;t<ary+n;t++)
        cout<<*t<<"  ";
    cout<<endl;
    for(i=0;i<n;i++) ary[i]=10+i;
    for(i=0;i<n;i++)  cout<<ary[i]<<" ";
    cout<<endl;
    delete []ary;
    ary=NULL;
}

void APP(int *pa,int len)
{
    pa=new int[len];
    if(pa==NULL)
    {
     cout<<"allocation faiure\n";
     return;
    }
    for(int i=0;i<len;i++) pa[i]=0;
}
搜索更多相关主题的帖子: 代码 
2010-07-16 23:24
草狼
Rank: 9Rank: 9Rank: 9
等 级:蜘蛛侠
威 望:2
帖 子:577
专家分:1040
注 册:2010-4-6
得分:0 
回复 2楼 最近不在
在问下哦,定义动态整型 int *p=new int;不能用cin>>p;来输入,那应该如何来输入p的值呢?
2010-07-17 14:21



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-313216-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.113119 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved