当前位置:网站首页>C language structure, function and pointer exercise (simple address book)

C language structure, function and pointer exercise (simple address book)

2022-08-10 01:47:00 BSP Junior Primary School Monk

#include #include typedef struct{char name[20];long long phone;char sex[10];char dress[20];int age;}Person;Person person_arr[20]={{"Xiong Da",10086,"Male","Henan",24},{"Xiong Er", 10010, "Male", "Shaanxi", 23},{"Xiong San",911,"Male","Hubei",25}};void add(){int i,n;printf("Please enter how many address book friends you need to add this time:\n");scanf("%d",&n);for(i=0;iperson_arr[j+1].age){temp=person_arr[j];person_arr[j]=person_arr[j+1];person_arr[j+1]=temp;}}}}int main(){int n=100;while(n != 0){printf("The information of this address book list is as follows:\n");print();printf("The function is as follows:\n");printf("1. Add friends 2. Delete friends\n");printf("3. Search friends 4. Modify friends\n");printf("5. Print friends 6. Sort contacts\n");printf("0, exit\n");scanf("%d", &n);switch(n){case 1:add();break;case 2:del();break;case 3:seek();break;case 4:modify();break;case 5:print();break;case 6:classfy();break;default :break;}}return 0;} 

Running result:

原网站

版权声明
本文为[BSP Junior Primary School Monk]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/222/202208092342344399.html