變數的三要素:
名字,記憶體位址,值
變數的左值,右值
左值指變數的記憶體位址
右值:值
在賦值表示式中,賦值號左邊需要左值,右邊需要右值;如a=a+100
指標變數
指標變數的右值本身又是乙個左值。
個人上課未理解的點:
頭指標:指向第乙個結點的指標,
鍊錶的定義:
struct node
頭指標的實現:
struct node first;
struct node *head=&first;//head為頭指標
頭結點:
在鍊錶的頭部附加乙個結點,該結點的資料域可不儲存任何資料
頭結點的實現
struct node *root,head,first;
root=&head;//head為頭結點,頭指標為指向頭結點的指標
root->data=0;
root->next=&first;
頭結點的作用:
1.防止單鏈表為空
2.方便單鏈表的特殊操作,如在表頭插入或刪除第乙個結點
單鏈表的實現
單鏈表的構造-頭插法template class linklist //建立空表
linklist ( t a[ ], int n ) ;
~linklist ( ) ;
};
1.建空表
2.申請新結點並賦值
3.插入新結點last=s;
4.執行的語句組為:s->next=first->next;first->next=s;
具體實現:
**每次插入的資料都是到first->next 中去template linklist:: linklist(t a[ ], int n)
}
**單鏈表的構造-尾插法
具體實現:
單鏈表的遍歷:template linklist:: linklist(t a[ ], int n)
r->next=null; //單鏈表建立完畢,將終端結點的指標域置空
}
template linklist:: printlist()
}```
實現三子棋程式 define crt secure no warnings include include include include intmenu define max row 3 define max col 3 void init char chessboard max row max ...
ObjC第四節 繼承
繼 承 1 繼承 1.1 nsobject,根類,oc建立的類都繼承自根類,位於類層次結構的頂層,沒有父類 1.2 父類的例項變數和方法都可以被隱式的繼承過來成為子類的一部分,子類就可以直接訪問這些例項變數和方法 1.3 alloc和init是繼承自nsobject的方法 1.4 繼承的概念呈單鏈繼...
第四節 條件語句
if語句 if v 100else if v 50elseif語句不需要括號 用法高階 const filename abc.txt if contents,error ioutil.readfile filename error nilelse注意 contents和error變數都是在if 塊中...