欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

C語言實(shí)現(xiàn)通訊錄管理系統(tǒng)

 更新時(shí)間:2021年01月02日 12:32:08   作者:萌面行者  
這篇文章主要為大家詳細(xì)介紹了C語言實(shí)現(xiàn)通訊錄管理系統(tǒng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了C語言實(shí)現(xiàn)通訊錄管理系統(tǒng)的具體代碼,供大家參考,具體內(nèi)容如下

工具:Visual C++6.0

說明:

本系統(tǒng)基于C語言實(shí)現(xiàn)班級(jí)通訊錄管理系統(tǒng),為大一時(shí)學(xué)習(xí)C語言剛?cè)腴T所做的課程設(shè)計(jì)。功能包括增、刪、查、改等,非常適合初學(xué)者練手。通訊錄包括的個(gè)人信息有姓名、學(xué)號(hào)、性別、籍貫、政治面貌、手機(jī)號(hào)、QQ號(hào)、宿舍等。主要用到了指針、結(jié)構(gòu)體、遍歷鏈表、文件讀取等知識(shí)點(diǎn)。

運(yùn)行效果:

代碼:

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<windows.h>
typedef struct student  //定義結(jié)構(gòu)體
{
 char name[20]; //姓名
 char num[15];  //學(xué)號(hào)
 char sex[10];  //性別
 char from[20]; //籍貫
 char political[10]; //政治面貌
 char phone[15];  //手機(jī)號(hào)
 char QQ[15];   //QQ號(hào)
 char dorm[10];  //宿舍
 struct student *next; //結(jié)構(gòu)體指針
}stu;
stu *head;

void print() //主菜單
{
 system("cls");
 printf("\n\n\n");
 printf("  ☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆\n");
 printf("  ***********************************************************\n");
 printf("  \t\t\t班級(jí)通訊錄管理系統(tǒng)\n");
 printf("\n");
 printf("  \t\t1. 輸入數(shù)據(jù)");
 printf("\t\t2. 顯示數(shù)據(jù)\n");
 printf("  \t\t3. 插入數(shù)據(jù)");
 printf("\t\t4. 刪除數(shù)據(jù)\n");
 printf("  \t\t5. 查看數(shù)據(jù)");
 printf("\t\t6. 修改數(shù)據(jù)\n");
 printf("  \t\t7. 保存數(shù)據(jù)");
 printf("\t\t8. 返回主菜單\n");
 printf("  ***********************************************************\n");
 printf("  ~~~~~退~~~~~~~~~~出~~~~~~~~~~請(qǐng)~~~~~~~~~~按~~~~~~~~~~9~~~~~\n");
 printf("  -----------------------------------------------------------\n\n");
}


void input(stu *p1) //輸入相關(guān)數(shù)據(jù)
{
 printf("姓名:");
 scanf("%s",&p1->name);
 printf("學(xué)號(hào):");
 scanf("%s",&p1->num);
 printf("性別:");
 scanf("%s",&p1->sex);
 printf("籍貫:");
 scanf("%s",&p1->from);
 printf("政治面貌:");
 scanf("%s",&p1->political);
 printf("手機(jī)號(hào):");
 scanf("%s",&p1->phone);
 printf("QQ號(hào):");
 scanf("%s",&p1->QQ);
 printf("宿舍:");
 scanf("%s",&p1->dorm);
}


stu * inputdata()  //數(shù)據(jù)輸入的函數(shù)
{
 stu *p1,*p2;
 int i=1;
 p1=(stu *)malloc(sizeof(stu));
 if(p1!=NULL)
 {
  head=p1;
  printf("\n\t\t\t☆☆☆輸入數(shù)據(jù)☆☆☆\n");
  printf("------------------------------------------------------------------\n");
  printf("在姓名處輸入“ok”代表輸入數(shù)據(jù)結(jié)束\n");
  while(i)
  {
   printf("姓名:");
   scanf("%s",&p1->name);
   if(strcmp(p1->name,"ok")==0)
   {
    printf("\n輸入完畢!\n");
    printf("========================================================================\n");
    i=0;
    p2->next=NULL;
    free(p1);
    p1=p2;
   }
   else
   {
    printf("學(xué)號(hào):");
    scanf("%s",&p1->num);
    printf("性別:");
    scanf("%s",&p1->sex);
    printf("籍貫:");
     scanf("%s",&p1->from);
    printf("政治面貌:");
    scanf("%s",&p1->political);
    printf("手機(jī)號(hào):");
    scanf("%s",&p1->phone);
    printf("QQ號(hào):");
    scanf("%s",&p1->QQ);
    printf("宿舍:");
    scanf("%s",&p1->dorm);
    printf("=====================================\n");
    p2=p1;
    p1=(stu *)malloc(sizeof(stu));
    if(p1!=NULL)
    {
     p2->next=p1;
    }
   }
  }
  return(p1->next);
 }
}


stu * lookdata(stu *p1)  //查看數(shù)據(jù)的函數(shù)
{
 printf("\n\t\t\t☆☆☆顯示數(shù)據(jù)☆☆☆\n");
 printf("----------------------------------------------------------------------\n");
 while(p1!=NULL)
 {
  printf("姓名:%s\n",p1->name);
  printf("學(xué)號(hào):%s\t",p1->num);
  printf("性別:%s\t",p1->sex);
  printf("籍貫:%s\t",p1->from);
  printf("政治面貌:%s\t",p1->political);
  printf("手機(jī)號(hào):%s\t",p1->phone);
  printf("QQ號(hào):%s\t",p1->QQ);
  printf("宿舍:%s\n",p1->dorm);
  printf("======================================================================\n");
  p1=p1->next;
 }
 return p1;
}


void insert()  //插入數(shù)據(jù)
{
 int i;
 char named[20];
 stu *p1,*p2,*p3;
 p1=head;
 p3=(stu *)malloc(sizeof(stu));
 p3->next=NULL;
 printf("\n\t\t\t☆☆☆插入數(shù)據(jù)☆☆☆\n");
 printf("----------------------------------------------------------------------\n");
 printf("請(qǐng)輸入插入者的資料:\n");
 input(p3);
 printf("\n插入選項(xiàng)\n");
 printf("1.首位置插入\t2.尾位置插入\t3.前插\n");
 printf("請(qǐng)輸入你的選擇:");
 scanf("%d",&i);
 switch(i)
 {
 case 1:p3->next=p1;
  head=p3;
  break;
 case 2:while(p1->next!=NULL)
   {
    p2=p1;
    p1=p1->next;
   }
  p1->next=p3;
  break;
 case 3:printf("請(qǐng)輸入姓名(前插):");
  scanf("%s",named);
  while(strcmp(named,p1->name)!=0)
  {
   p2=p1;
   p1=p1->next;
  }
  p2->next=p3;
  p3->next=p1;
  break;
 }
 printf("插入成功!\n");
 printf("======================================================================\n");
 return;
}

void deleted()   //刪除數(shù)據(jù)
{
 stu *p1,*p2;
 char Name[20]; //想要?jiǎng)h除的人的姓名
 printf("\n\t\t\t☆☆☆刪除數(shù)據(jù)☆☆☆\n");
 printf("----------------------------------------------------------------------\n");
 printf("請(qǐng)輸入要?jiǎng)h除的姓名:");
 scanf("%s",Name);
 p1=head;
 if(head==NULL)
 {
 printf("內(nèi)存空空神馬都沒有!\n");
 printf("======================================================================\n");
 return;
 }
 if(strcmp(Name,p1->name)==0)
 {
 head=p1->next;
 printf("刪除成功!\n");
 printf("======================================================================\n");
 return;
 }
 while(p1!=NULL&&(strcmp(Name,p1->name)!=0))
 {
 p2=p1;
 p1=p1->next;
 }
 if(p1==NULL)
 {
 printf("此人不存在!\n");
 printf("======================================================================\n");
 return;
 }
 if(p1->next!=NULL)
 {
 p1=p1->next;
 p2->next=p1;
 printf("刪除成功!\n");
 printf("======================================================================\n");
 return;
 }
 else
 {
 p2->next=NULL;
 printf("刪除成功!\n");
 printf("======================================================================\n");
 return;
 }
}


find(stu *p2)  //通過姓名查找查看數(shù)據(jù)的函數(shù)
{
 char name[20];
 int b=0;
 printf("\n\t\t\t☆☆☆查看數(shù)據(jù)☆☆☆\n");
 printf("----------------------------------------------------------------------\n");
 printf("請(qǐng)輸入您想查找人的姓名:");
 scanf("%s",name);
 while(p2!=NULL)
 {
  if(strcmp(name,p2->name)==0)
  {
   printf("你要找到的數(shù)據(jù)\n");
   printf("姓名:%s\n",p2->name);
   printf("學(xué)號(hào):%s\t",p2->num);
   printf("性別:%s\t",p2->sex);
   printf("籍貫:%s\t",p2->from);
   printf("政治面貌:%s\t",p2->political);
   printf("手機(jī)號(hào):%s\t",p2->phone);
   printf("QQ號(hào):%s\t",p2->QQ);
   printf("宿舍:%s\n",p2->dorm);
   printf("======================================================================\n");
   b=1;
  }
  p2=p2->next;
 }
 if(b==0)
 {
  printf("\n您要查找的人不存在!\n");
 }
}


update(stu *p2) //通過姓名查找修改數(shù)據(jù)
{
 char name[20];
 int b=0,i;
 printf("\n\t\t\t☆☆☆修改數(shù)據(jù)☆☆☆\n");
 printf("----------------------------------------------------------------------\n");
 printf("請(qǐng)輸入將要修改人的姓名:");
 scanf("%s",name);
 while(p2!=NULL)
 {
  if(strcmp(name,p2->name)==0)
  {
   printf("該同學(xué)的基本信息\n");
   printf("姓名:%s\n",p2->name);
   printf("學(xué)號(hào):%s\t",p2->num);
    printf("性別:%s\t",p2->sex);
   printf("籍貫:%s\t",p2->from);
   printf("政治面貌:%s\t",p2->political);
   printf("手機(jī)號(hào):%s\t",p2->phone);
   printf("QQ號(hào):%s\t",p2->QQ);
   printf("宿舍:%s\n",p2->dorm);
   printf("\n請(qǐng)選擇要修改的信息\n");
   printf("\t1.姓名\t2.學(xué)號(hào)\t3.性別\t4.籍貫\n\t5.政治面貌\t6.手機(jī)號(hào)\t7.QQ\t8.宿舍\n");
   printf("\n您的選擇是(1~8):");
   scanf("%d",&i);
   printf("請(qǐng)輸入修改之后的內(nèi)容\n");
   switch(i)
   {
   case 1:printf("姓名:");
    scanf("%s",&p2->name);
    break;
   case 2:printf("學(xué)號(hào):");
    scanf("%s",&p2->num);
    break;
   case 3:printf("性別:");
    scanf("%s",&p2->sex);
    break;
   case 4:printf("籍貫:");
    scanf("%s",&p2->from);
    break;
   case 5:printf("政治面貌:");
    scanf("%s",&p2->political);
    break;
   case 6:printf("手機(jī)號(hào):");
    scanf("%s",&p2->phone);
    break;
   case 7:printf("QQ:");
    scanf("%s",&p2->QQ);
    break;
   case 8:printf("宿舍:");
    scanf("%d",&p2->dorm);
    break;
   }
   printf("\n修改成功!\n");
   printf("=========================================================================\n");
   b=1;
  }
  p2=p2->next;
 }
 if(b==0)
 {
  printf("沒有找到該人的資料!\n");
 }
}


save(stu *p2) //保存數(shù)據(jù)
{
 FILE *fp;
 char file[15];
 printf("\n\t\t\t☆☆☆保存數(shù)據(jù)☆☆☆\n");
 printf("----------------------------------------------------------------------\n");
 printf("輸入文件名:");
 scanf("%s",file);
 if((fp=fopen(file,"w"))==NULL)
 {
  printf("cannot open this file\n");
  exit(0);
 }
 fprintf(fp,"姓名\t學(xué)號(hào)\t性別\t籍貫\t政治面貌\t手機(jī)號(hào)\tQQ號(hào)\t宿舍\n");
 while(p2!=NULL)
 {
  fprintf(fp,"%s\t",p2->name);
  fprintf(fp,"%s\t",p2->num);
  fprintf(fp,"%s\t",p2->sex);
  fprintf(fp,"%s\t",p2->from);
  fprintf(fp,"%s\t",p2->political);
  fprintf(fp,"%s\t",p2->phone);
  fprintf(fp,"%s\t",p2->QQ);
  fprintf(fp,"%s\n",p2->dorm);
  p2=p2->next;
 }
 printf("\n保存成功!\n");
 printf("======================================================================\n");
 fclose(fp);
}


void screen()
{
 int i;
 char s[251]={"歡迎使用由ZM制作班級(jí)通訊錄管理系統(tǒng),\n\n\t\t\t本系統(tǒng)用于通訊錄管理----排序,打印\n\n\n\t\tWelcome to use produced by ZM class address book\n\n\t\t management system,sorting,printing"};

 printf("\n================================================================================\n");
 printf("\n\n\n\t\t\t");
 for(i=0;s[i]!=NULL;i++)
 {
  Sleep(30);
  printf("%c",s[i]);
 }
 printf("\n\n\n\n\n\n\n\n\t\t ~ Hi~ o(* ̄▽ ̄*)ブ~ ~ ~祝您旅途愉快~ ~\n");
 printf("================================================================================\n");

}


void main()
{
 int i;
 system("color 4e");
 screen();
 Sleep(3000);
 print();
 while(1)
 {
  printf("請(qǐng)輸入你的選擇(1~9):");
  loop:scanf("%d",&i);
  if(i<1||i>9)
  {
   printf("輸入有誤,請(qǐng)?jiān)?~9中進(jìn)行選擇:");
   goto loop;
  }
  switch(i)
  {
  case 1:
   inputdata();
   break;
  case 2:
   lookdata(head);
   break;
  case 3:
   insert();
   break;
  case 4:
    deleted();
   break;
  case 5:
   find(head);
   break;
  case 6:
   update(head);
   break;
  case 7:
   save(head);
   break;
  case 8:
   print();
   break;
  case 9:
   exit(1);
   break;
  }
 }
}

以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • C++重載運(yùn)算符的規(guī)則詳解

    C++重載運(yùn)算符的規(guī)則詳解

    運(yùn)算符重載函數(shù)可以是類的成員函數(shù),也可以是類的友元函數(shù),還可以是既非類的成員函數(shù)也不是友元函數(shù)的普通函數(shù)
    2013-10-10
  • Qt5多線程編程的實(shí)現(xiàn)

    Qt5多線程編程的實(shí)現(xiàn)

    Qt通過三種形式提供了對(duì)線程的支持,本文主要介紹了Qt5多線程編程的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-12-12
  • C++實(shí)現(xiàn)希爾排序(ShellSort)

    C++實(shí)現(xiàn)希爾排序(ShellSort)

    這篇文章主要為大家詳細(xì)介紹了C++實(shí)現(xiàn)希爾排序,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2020-04-04
  • sdl顯示一張bmp圖片示例

    sdl顯示一張bmp圖片示例

    這篇文章主要介紹了sdl顯示一張bmp圖片示例,需要的朋友可以參考下
    2014-04-04
  • C++11-20 常量表達(dá)式的使用

    C++11-20 常量表達(dá)式的使用

    本文主要介紹了C++11-20常量表達(dá)式,文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-10-10
  • C++的std::vector<bool>轉(zhuǎn)儲(chǔ)文件問題

    C++的std::vector<bool>轉(zhuǎn)儲(chǔ)文件問題

    這篇文章主要介紹了C++的std::vector<bool>轉(zhuǎn)儲(chǔ)文件問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-11-11
  • 排列組合總結(jié):將結(jié)果進(jìn)行輸出的實(shí)現(xiàn)方法

    排列組合總結(jié):將結(jié)果進(jìn)行輸出的實(shí)現(xiàn)方法

    本篇文章關(guān)于排列組合的總結(jié),對(duì)結(jié)果進(jìn)行輸出做了介紹。需要的朋友參考下
    2013-05-05
  • C語言實(shí)現(xiàn)隨機(jī)生成6位數(shù)密碼

    C語言實(shí)現(xiàn)隨機(jī)生成6位數(shù)密碼

    這篇文章主要為大家詳細(xì)介紹了如何使用C語言實(shí)現(xiàn)一個(gè)簡單而實(shí)用的隨機(jī)密碼生成器,該生成器將生成包含字母、數(shù)字和特殊字符的隨機(jī)密碼,有需要的小伙伴可以參考下
    2023-11-11
  • FFRPC應(yīng)用 Client/Server使用及原理解析

    FFRPC應(yīng)用 Client/Server使用及原理解析

    這篇文章主要介紹了FFRPC應(yīng)用 Client/Server使用及原理解析,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2019-08-08
  • 深入解析C++ STL中的常用容器

    深入解析C++ STL中的常用容器

    這里我們不涉及容器的基本操作之類,只是要討論一下各個(gè)容器其各自的特點(diǎn)。STL中的常用容器包括:順序性容器(vector、deque、list)、關(guān)聯(lián)容器(map、set)、容器適配器(queue、stac)
    2013-09-09

最新評(píng)論