-
靜態鏈表: struct weapon { ?int price; ?int atk; ?struct weapon *next; //指向下一個節點 }; struct weapon a,b,c,*head; head = &a; a.next = &b; b.next = &c; c.next = NULL;
查看全部 -
動態鏈表: #include<malloc.h> //注意加這個頭文件 struct weapon *create() //creat函數 { ?struct weapon *head; ?struct weapon *p1, *p2; ?int n=0; ?p1=p2=(struct weapon*)malloc(sizeof(struct weapon)); ?//malloc 分配內存塊的函數,sizeof判斷數據類型長度符; ?scanf("%d,%d",&p1->price,&p1->atk); ?head = NULL; ?//初始化第一個結點 ?while(p1->price!=0) ? ?//結束開辟結點判定條件 ?{ ? ?n++; ? ?if(n==1) ?head=p1; ? ?else p2->next=p1; ? ?p2=p1; ? ?p1=(struct weapon*)malloc(sizeof(struct weapon)); ? ?scanf("%d,%d",&p1->price,&p1->atk); ?} ?p2->next = NULL; ?retrun(head); }
查看全部 -
按位異或,1.定位反轉,2.數值交換的功能。
查看全部 -
或運算,1.設定數據的指定位。
查看全部 -
按位與三個簡單應用,1.迅速清零。2.保留特定位的數據。3.判斷奇偶性。
查看全部 -
typedef 給變量類型取別名。
查看全部 -
宏的本質:宏替換就是指在預處理階段的,單純的字符串的替換。
查看全部 -
編譯的四個步驟。預處理是第一個步驟。預處理做的第一件事兒就是展開了c的頭文件。另外一件事就是宏替換。還提供了一個功能是條件編譯。
查看全部 -
遞歸與遞推的區別
查看全部 -
訪問結構體成員,用(*w).name還是w->name還是w.name都是可以地,C語言底層進行了屏蔽
查看全部 -
預處理->編譯->匯編->鏈接
查看全部 -
簡化后代碼,并且分析了各作用 ,分層明確,容易懂和識別
#include <stdio.h>
#include <malloc.h>?
struct weapon { //這層函數作用設立變量名和這節函數指針
?int price;
?int atk;
?struct weapon * next;
};
struct weapon * create(){
struct weapon * head; ? ? ? ? ? struct weapon * p1,*p2; //創建頭指針和節點指針?
head,p2->next =NULL;//頭指針和節點指針,都需要放數據所以需要注空?
p1=(struct weapon *)malloc(sizeof(struct weapon));//建立第一節點空間,并可以輸入
scanf("%d,%d",&p1->price,&p1->atk);?
int n=0;//循環并設立指向頭指針和p2指針方向?
while(p1,p2->price!=0){
?n++;
?if(n==1) head=p1;
else p2->next=p1;
p2=p1;
?
?p2=(struct weapon*)malloc(sizeof(struct weapon));// 建立第二節點空間?
?scanf("%d,%d",&p2->price,&p2->atk);
}
return (head); ?
}
int main(){//建立前2個函數指針并指引然后運行函數輸出
struct weapon * p;
p=create();
printf("%d,%d",p->atk,p->price);
return 0;
}
查看全部 -
.c文件(預處理) --> ?.i文件(編譯) -->.s文件(匯編) --> .o文件(鏈接)-->可執行文件查看全部
-
1.
查看全部 -
左移(高位丟棄,地位補0):將值乘以2的N(左移位數)次方、實現乘數為2的運算。問題:有符號位,容易移除
左移(低位丟棄,高位根據情況補):將值除以2的N(左移位數)次方、實現除數為2的運算。問題:有符號位,高位根據計算機補位,無符號為,高位補0
查看全部
舉報