通讯录删除(by id or name or num)
来源:互联网 发布:sqlite数据库加密 编辑:程序博客网 时间:2024/06/15 19:32
int delete_id(node head, int* n, int i){node t = NULL;while(head->next->data.id != i){head = head->next;}t = head->next->next;free(head->next);head->next = t;while(head->next != NULL){head = head->next;head->data.id--;}--*n;return T;}int delete_name(node head, int* n){char s[15];printf("who you want to delete?\n");scanf("%s", s);while(head->next != NULL){if(strcmp(head->next->data.name, s) == 0){delete_id(head, n, head->next->data.id);}else{head = head->next;}}return T;}int delete_num(node head, int* n){char s[15];printf("which num you want to delete?\n");scanf("%s", s);while(head->next != NULL){if(strcmp(head->next->data.num, s) == 0){delete_id(head, n, head->next->data.id);}else{head = head->next;}}return T;}主函数:
int init(node*);//初始化int interface(void);//功能列表type insert_tail(node);//从尾部插入int insert_id(node, int*);//由id插入int delete_id(node, int*, int);//根据id删除int delete_name(node, int*);//根据name删除int delete_num(node, int*);//根据num删除void print(node head);//打印int main(){node head;int ret = 0;int n = 0;int n1 = 0;int d = 0;int i = 0;init(&head);for(;ret != 8;){ret = interface();switch(ret){case 1:printf("how many contacts you want to put in?\n");scanf("%d", &n);n1 = n;for(;n1 > 0; n1--){insert_tail(head);}break;case 2:insert_id(head, &n);printf("%d", n);break;case 3:printf("You want to delete by 1.id or 2.name or 3.num\n");scanf("%d", &d);if(1 == d){printf("which id you want to delete?\n");scanf("%d", &i);delete_id(head, &n, i);}else if(2 == d){delete_name(head, &n);}else if(3 == d){delete_num(head, &n);}else {printf("Warning:wrong function!\n");}break;case 7:print(head);break;case 8:break;default:printf("Warning:wrong function!\n");break;}}return 0;}
阅读全文
0 0
- 通讯录删除(by id or name or num)
- name or id ?
- Change Host Name or Port Num in R12 EBS
- Linux change or rename user name and UID (user-id)
- DB logical id or ?
- and,or,order by
- By value? Or by reference?
- Get Process ID by Name
- Name or service not known
- ORA-01688:unable to extend table name。name partition NAME by NUM in tablespace NAME
- DB server name OR DB cluster name?
- Add enum alias name or change name
- Selenium寻找元素定位 id findElement(by.id(“id”)) name findElement(by.name(“name”)) class_name findE
- mongo : query multi cols by "and" or by "or"
- call by value or reference ?
- call by value or reference
- call by value or reference
- call by value or reference
- java jdk win配置环境变量
- docker-compose搭建Nginx+Tomcat负载均衡环境
- 离散题目13
- 今日问题记录-1
- 数组的应用---随机点学号
- 通讯录删除(by id or name or num)
- Cactus UVALive
- Android DataBinding使用总结(一)
- [LeetCode 解题报告]005.Longest Palindromic Substring
- 王怡 | 微读(01-23)
- sqlite3使用
- android studio中的竖线怎么去掉
- 手势解锁
- JavaScript