成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

c語言鏈表的頭插,尾插,遍歷,以及交換末尾值-創(chuàng)新互聯(lián)

#include#include#includestruct S{
	int data;
	struct S* next;
};
struct S *CreateListL(void){//head_inserting linked list
	struct S *head,*p;
	int data;
	head = NULL;
	scanf("%d",&data);
	while(data != 0){
		p = (struct S *)malloc(sizeof(struct S));
		p->data = data;
		p->next = head;
		head = p;
		scanf("%d",&data);
	}
	return head;
}

struct S*CreateListR(void){//rear_inserting linked list
	struct S *head,*rear,*p;
	int data;
	head = NULL;
	scanf("%d",&data);
	while(data != 0){
		p = (struct S *)malloc(sizeof(struct S));
		p->next = NULL;
		p->data = data;
		if(!head)
			head = p;
		else 
		    rear->next=p;
		rear = p;
		scanf("%d",&data);	
		
	}
	return head;
}
void PrintList(struct S *head){//print the linked list
	struct S *p=head;
	while(p&&p->next!=NULL){
		printf("%d ",p->data);
		p=p->next;
	}	
	printf("%d\n",p->data);// modify it to meet the standard
}

struct S *Exchange(struct S*head){//exchange the last two elements in the linked list
	struct S *p=head;
	while(p->next->next!=NULL){
		printf("%d ",p->data);
		p=p->next;
	}
	struct S *q=p;
	p=p->next;
	printf("%d ",p->data);
	printf("%d ",q->data);
	free(q);
}

int main(){
	int i;
	struct S* p;
	printf("Head Insertion, Data = ");	
	p = CreateListL();
	PrintList(p);
	//尾插法建立鏈表
	printf("Tail Insertion, Data = ");
	p = CreateListR();
	PrintList(p);// change the last two elements in the linked list
	p=Exchange(p);
	PrintList(p);
	return 0;
}

你是否還在尋找穩(wěn)定的海外服務(wù)器提供商?創(chuàng)新互聯(lián)www.cdcxhl.cn海外機房具備T級流量清洗系統(tǒng)配攻擊溯源,準確流量調(diào)度確保服務(wù)器高可用性,企業(yè)級服務(wù)器適合批量采購,新人活動首月15元起,快前往官網(wǎng)查看詳情吧

創(chuàng)新互聯(lián)建站成立于2013年,先為宜都等服務(wù)建站,宜都等地企業(yè),進行企業(yè)商務(wù)咨詢服務(wù)。為宜都企業(yè)網(wǎng)站制作PC+手機+微官網(wǎng)三網(wǎng)同步一站式服務(wù)解決您的所有建站問題。

文章標題:c語言鏈表的頭插,尾插,遍歷,以及交換末尾值-創(chuàng)新互聯(lián)
轉(zhuǎn)載注明:http://jinyejixie.com/article12/hgodc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供移動網(wǎng)站建設(shè)外貿(mào)網(wǎng)站建設(shè)、網(wǎng)站營銷、網(wǎng)站維護、App開發(fā)、標簽優(yōu)化

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)頁設(shè)計公司
盐源县| 荔波县| 蚌埠市| 博兴县| 中江县| 淳化县| 会泽县| 陆丰市| 唐河县| 宁波市| 通城县| 临西县| 图木舒克市| 普兰店市| 汉沽区| 洱源县| 鹤山市| 读书| 松潘县| 古交市| 利川市| 黄陵县| 万全县| 肥东县| 辰溪县| 大关县| 和硕县| 满城县| 辽源市| 临海市| 隆安县| 鄄城县| 泰宁县| 长丰县| 九江市| 开封县| 南京市| 浦江县| 南和县| 丘北县| 兰西县|