1、在指定位置插入结点的操作 void inert(void i char numstr[20]; if (head==nULl return; IS-heae, printf("input num”); gets(numstr); do i if (this->num-==atol(numstr)) i new=(struct stud*)malloc(sizeof(struct stud) new->next=this->next this-next=new: gets(new->name); this=this->next: ) while(this!=NULL)
1、在指定位置插入结点的操作 void indert(void) { char numstr[20]; if (head==NULL) return; this=heae; printf(“input num”); gets(numstr); do { if (this->num==atol(numstr)) { new=(struct stud *)malloc(sizeof(struct stud)); new->next=this->next; this-next=new; gets(new->name); : } this=this->next; }while(this!=NULL); }
2、删除指定结点的操作 void delete(void) i char numstr[]; if (head==nUll return; this=heae: new=this: printf("input num”); gets(numstr); d f if (new->num==atol(numstr)) if head==new) head=new->next else this->next=new->next this=new; new=new->next )while(new!=NULL);
2、删除指定结点的操作 void delete(void) { char numstr[20]; if (head==NULL) return; this=heae;new=this; printf(“input num”); gets(numstr); do { if (new->num==atol(numstr)) if ( head==new) head=new->next; else this->next=new->next; this=new; new=new->next; }while(new!=NULL); }
本次课内容:位运算概述和位运算使用方法 教学目的:掌握相关概念、定义、运算符和引用方法。 重点:相关概念,运算符、定义、引用。 难点:引用及特殊环境的引用。 预习: 二进制表示方法,原码、反码和补码。 有符号数和无符号数
本次课内容:位运算概述和位运算使用方法 教学目的:掌握相关概念、定义、运算符和引用方法。 重点:相关概念,运算符、定义、引用。 难点:引用及特殊环境的引用。 预习: 二进制表示方法,原码、反码和补码。 有符号数和无符号数
位运算概述 1、位状态和位运算 (1)数据以二进制表示时的信号每一位的0或1的状态,称为一个 “位”(bi的状态。 如:10011001 (2)对数据的某些位进行的操作。如:接位取反等。 2、运算符 位运算符含义 举例 按位取反~a,对变量a中全部位取反 左移 a<<2,a中各位全部左移2位 右移 a>2,a中各位全部右移2位 & 按位与 a&b,a和b中各位按位进行“与”运算 按位或 a|b,a和b各位按位进行“或”运算 按位异或a^b,a和b中各位按位进行“异或”运 算
一、位运算概述 1、位状态和位运算 (1)数据以二进制表示时的信号每一位的0或1的状态,称为一个 “位”(bit)的状态。 如:10011001 (2)对数据的某些位进行的操作。如:接位取反等。 2、运算符 位运算符 含义 举例 ~ 按位取反 ~a,对变量a中全部位取反 << 左移 a<<2,a中各位全部左移2位 >> 右移 a>>2, a中各位全部右移2 位 & 按位与 a&b, a和b中各位按位进行“与”运算 | 按位或 a | b ,a和b各位按位进行“或”运算 ^ 按位异或 a^b, a和b中各位按位进行“异或”运 算