帮别人改的DS课设2

#include<stdio.h>
#include<malloc.h>
#include<stdlib.h>
#include<string.h>
#define MAX 10
int count=0;
typedef struct   /*个人信息纪录节点*/
{
char name[10];
char tel[20];
char addr[50];
}personnode;

personnode paixu(personnode person[MAX]) 
{
    int j,exchange,bound;
    personnode key;
    exchange=count;
    while(exchange)
    {
        bound=exchange;
        exchange=0;
        for(j=0; j<bound; j++)
  {
           if(strcmp(person[j].name,person[j+1].name)>0)
        {
               key=person[j];
               person[j]=person[j+1];
               person[j+1]=key;
               exchange=j;
           }
        }
 }
    printf("排序成功!/n");
    return person[MAX];
}
personnode Create(personnode person[MAX]) /*创建电话号码查询系统*/
{
    printf("/n请输入姓名,电话号码及住址(输入quit结束创建新数据库):");
    count++;
    while(count<=MAX)
    {
  scanf("%s",person[count].name);
  if(strcmp(person[count].name,"quit")==0)break;
        scanf("%s%s",person[count].tel,person[count].addr);
        printf("%s-%s-%s/n",person[count].name,person[count].tel,person[count].addr);
        count++;
        printf("/n请输入姓名,电话号码及住址(输入quit结束创建新数据库):");
    }
 count--;
 paixu(person);
    printf("系统创建成功!/n");
    return person[MAX];  
}

int Search_Bin(personnode person[MAX],char key[])
{
    int low=1, high=count,mid;
    while(low<=high)
    {
         mid=(low+high)/2;
         if(strcmp(key,person[mid-1].name)==0)
               return mid;
         else if(strcmp(person[mid-1].name,key)>0)
               high=mid-1;
         else
               low=mid+1;
    }
    return 0;
}
void Search(personnode person[MAX])   /*查找信息*/
{     
    int i=0;
    char namekey[10];
    printf("/n请输入要查询的姓名:   /n");
    scanf("%s",&namekey);
    i=Search_Bin(person,namekey);
 if(i!=0)
 {
       printf("您所要查找的人的信息为:");
       printf("%s-%s-%s",person[i-1].name,person[i-1].tel,person[i-1].addr);
 }
    else
       printf("输入的姓名不存在!/n");
}

personnode Modify(personnode person[MAX]) /*修改个人信息*/
{
    int i;
    personnode personkey;
    int Search_Bin(personnode person[MAX],char key[10]);
    printf("/n请输入要修改人的信息:   /n");
    scanf("%s%s%s",&personkey.name,&personkey.tel,&personkey.addr);
    i=Search_Bin(person,personkey.name);
    if(i!=0)
 {
    printf("/n 所修改人的原信息:   /n");
    printf("%s-%s-%s",person[i-1].name,person[i-1].tel,person[i-1].addr);
    person[i-1]=personkey;
    printf("修改成功!");
 }
    else
    printf("输入的姓名不存在!");
    paixu(person);
    return person[MAX];
}
personnode Deleterecord(personnode person[MAX]) /*删除个人信息*/
{
    int i,j;
    char ch;
    char namekey[10];
    int Search_Bin(personnode person[MAX],char key[10]);
    printf("/n请输入要删除人的姓名:   /n");
    scanf("%s",&namekey);
    i=Search_Bin(person,namekey);
    if(i!=0)
 {
       printf("已查到,记录为:");
       printf("/n%s-%s-%s/n",person[i-1].name,person[i-1].tel,person[i-1].addr);
       printf("确实要删掉吗,'y'or'n'?/n");
       getchar();
       scanf("%c",&ch);
       if(ch=='y')
    {
       for(j=i-1;j<=count;j++)
          person[j]=person[j+1];
       printf("删除成功!");
       count--;
       // printf("%d",count);
    }
 }
    else
    printf("输入的姓名不存在!");
 paixu(person);
    return person[MAX];
}

void Output(personnode person[MAX])    /*浏览整个查询系统*/
{
    int i;
    printf("/n-------------------------------------/n");
    printf("          电话号码查询系统             /n");
    printf("姓名-电话号码-住址/n");
    printf("%d/n",count);
    for(i=0;i<count;i++)
    {
  printf("%s-%s-%s/n",person[i].name,person[i].tel,person[i].addr);
    }     
    printf("-----------------------------------/n");
}

personnode Append(personnode person[MAX]) /*添加新信息*/
{
    int i=count;
    personnode key;
    printf("/n请输入要添加的姓名,电话和住址: /n");
    scanf("%s%s%s",&key.name,&key.tel,&key.addr);
    while(strcmp(person[i].name,key.name)>0)  
    {
        person[i+1]=person[i];
        i--;
 }
    person[i+1]=key;
    printf("%s-%s-%s/n",person[i+1].name,person[i+1].tel,person[i+1].addr);
    printf("添加成功!");
    count=count+1;
    // printf("%d",count);
 paixu(person);
    return person[MAX];           
}

int menu()      /*菜单打印函数*/
{
 int i;
    printf("---------电话号码查询系统-----------/n/n");
    printf("   |    1: 创建新数据库       |    /n");
    printf("   |    2: 添加新号码         |    /n");
    printf("   |    3: 查找               |    /n");        
    printf("   |    4: 修改               |    /n");
    printf("   |    5: 删除               |    /n");
    printf("   |    6: 浏览               |    /n");
    printf("   |    7: 退出 !            |    /n");
    printf("------------------------------------/n");
 printf("/n   请输入你要执行的操作:    /n");
    scanf("%d",&i); /* 接收用户的命令 */
 return i;
}
void main()
{
   personnode person[MAX];
   int quit=0;   
   while(!quit)
   {
       
        switch(menu())
  {
            case 1: Create(person);break;
            case 2: Append(person);break;
            case 3: Search(person);break;
            case 4: Modify(person);break;
            case 5: Deleterecord(person);break;
            case 6: Output(person);break;           
            case 7: quit=1;break;
            default:printf("输入错误!/n");break;
       }
   }
}

时间: 2024-09-20 04:06:48

帮别人改的DS课设2的相关文章

帮别人改的DS课设9

#include <stdio.h> #include <malloc.h> #include <string.h>#include <stdlib.h>  #define   MaxNumber   100 typedef   struct{     char   name[20];     char   sex[4];   /*性别,'F'表示女性,'M'表示男性*/     }Person;   /*   将队列中元素的数据类型改为Person*/ t

帮别人改的DS课设7

#include <iostream.h>#include <stdio.h>#include <stdlib.h>#include <conio.h>#define OK 1#define OVERFLOW -1#define ERROR 0typedef int Status; int boyscount=0,girlscount=0;    //全局变量int Lcm(int ,int );            //求最小公倍数(lease comm

帮别人改的DS课设4

#include <stdio.h>#include <stdlib.h>#include <string.h>//构造huffman树类型typedef struct        {    char self;     //字符存储    int weight;     //权值存储    int parent,lchild,rchild; //结点存储    int flag;      //存在判断}HuffmanTree;//构造huffman编码临时存储类型

帮别人改的DS课设5

#include<iostream.h>#include<stdio.h>#include<stdlib.h>#include<string.h>int s1,s2,selfnumber;        //s1,s2存储最小和次小的两个结点,selfnumber存储出现字符个数 //构造HuffmanTree类型typedef struct        { char self;        //字符存储 int weight;        //权值存

帮别人改的DS课设3

#include "stdio.h"#include "string.h" #define NULL 0#define m 20unsigned int key;unsigned int key2;    int *p;struct node //建节点{   char name[8],address[20];   char num[11];        node * next;}; typedef node* pnode;typedef node* mingzi

帮别人改的DS课设8

#include <iostream.h>#include  <malloc.h>#include  <stdio.h>#include <stdlib.h>#include  <conio.h> #define OK   1#define ERROR  0#define FALSE  0#define TRUE  1#define OVERFLOW -2#define MAXQSIZE 101  //最大队列长度 typedef char QE

ultisim 数字电路-求交通灯控制器ms文件,数电课设,Multisim仿真

问题描述 求交通灯控制器ms文件,数电课设,Multisim仿真 要求: 1.东西方向为主干道,南北方向为副干道: 2._主干道通行40秒后,若副干道无车,仍主干道通行,否则转换:_ 4.换向时要有4秒的黄灯期: 5._南北通行时间为20秒,到时间则转换,若未到时,但是南北方向已经无车,也要转换_. 6.用数码管显示计时.能够附加各部分的解释说明就更好了!!大神们,帮帮忙吧!!急求,望找不到问题所在或者直接提示我上网搜的各位不要吐槽

mfc-MFC课设时做了一个bmp格式转jpg格式出错,求大神解答

问题描述 MFC课设时做了一个bmp格式转jpg格式出错,求大神解答 BmpVsJpgDlg.obj : error LNK2001: unresolved external symbol "public: int thiscall CDib::Write(class CFile *)" (?Write@CDib@@QAEHPAVCFile@@@Z) BmpVsJpgDlg.obj : error LNK2001: unresolved external symbol "pu

mfc求助-基于MFC期刊管理信息系统的课设

问题描述 基于MFC期刊管理信息系统的课设 比较全面的课程设计!文件含有源代码!还有?dsw格式的文件!如果有其他的更好! 解决方案 http://www.docin.com/p-806155194.html 解决方案二: http://www.pudn.com/downloads701/ebook/detail2821802.html 解决方案三: 这种东东,你只能去网上查找,如果有是最好的.'没有,别人也不太可能去为你开发的 .