一维数组传递 sizeof不起作用

#include<iostream>
using namespace std;
typedef int type;
struct node{
	type date;
	node * link;
}; 
node * createList(int a [],int c){
	//cout<<sizeof(a);
	//cout<<sizeof(int);
	//cout<<a[3];
	int len=c;
	//cout<<len;
	node *head;
	node *p=new node;
	p->date=a[0];
	head=p;
	for(int i=1;i<len;i++){
		node *p1=new node;
		p1->date=a[i];
		p->link=p1;
		p=p1;
	}
	p->link=NULL;
	return head;
}
node* reverse(node * head){
	node *p,*p1,*p2;
	p1=NULL;
	p2=head;
	p=p2->link;
while(p!=NULL)
{
	p2->link=p1;
	p1=p2;
	p2=p;
	p=p->link;
}
p2->link=p1;
head=p2;
return head;
}
void print(node *head){
	node *p=head;
	for(;p!=NULL;p=p->link){
		cout<<p->date<<"  ";
	}
	cout<<endl;
}
int main(){
	int b[]={1,3,4,5};
	//cout<<sizeof(b);
	node *head=createList(b,4);
	//node *head1=reverse(head);
	print(head);
//	print(head1);
}


转载于:https://my.oschina.net/yanjianhai/blog/223737

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值