成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

C語(yǔ)言使用順序表實(shí)現(xiàn)電話本功能-創(chuàng)新互聯(lián)

 簡(jiǎn)介:

網(wǎng)站建設(shè)哪家好,找創(chuàng)新互聯(lián)建站!專注于網(wǎng)頁(yè)設(shè)計(jì)、網(wǎng)站建設(shè)、微信開(kāi)發(fā)、微信平臺(tái)小程序開(kāi)發(fā)、集團(tuán)企業(yè)網(wǎng)站建設(shè)等服務(wù)項(xiàng)目。為回饋新老客戶創(chuàng)新互聯(lián)還提供了宜興免費(fèi)建站歡迎大家使用!

用順序表實(shí)現(xiàn)電話本的功能(C語(yǔ)言)

電話本具有如下4個(gè)功能:

1.創(chuàng)建一個(gè)電話本,電話本里面包含名字和電話號(hào)碼
2.在指定位置插入一個(gè)名字和電話號(hào)碼
3.在指定位置刪除一個(gè)名字和電話號(hào)碼
4.打印電話本

代碼:

//其中那個(gè)color函數(shù)是我為了美觀加上去的,如果感覺(jué)不需要的話可以將代碼中所有有關(guān)color的都刪掉即可

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <windows.h>
using namespace std;
const int N = 1000+10;
int n;
struct Node
{
  char name[100];
  char number[20]; 
};
typedef struct 
{
  struct Node* mylist;
  int len;
  int listsize;
}sqlist;

void Init(sqlist &s1);
void Creat(sqlist &s1);
void Delet(sqlist &s1);
void Add(sqlist &s1);
void Print(sqlist &s1);
void color(const unsigned short color1);

int main()
{
  sqlist s1;
  Init(s1);
  color(10);
  printf("\n\n\n\n    --------------- WSM's phonetxt-------------------\n\n");
  printf("       |You could chose these ops:      |\n");
  printf("       |  1.Creat the phonetxt        |\n");
  printf("       |  2.Delet the member in the phonetxt |\n");
  printf("       |  3.Add the member in the phonetxt  |\n");
  printf("       |  4.Print the phonetxt        |\n");
  color(14);
  printf("\n\n\n\n   Now,you can enter an optiton:");

  int op;
  while(scanf("%d",&op)!=EOF)
  {
    if(op==1) Creat(s1);
    else if(op==2) Delet(s1);
    else if(op==3) Add(s1);
    else if(op==4) Print(s1);
    else 
    {
      color(4);
      printf("   You input is invalid,reinput please:)\n");
      color(14);
    }
    printf("\n   Now,you can enter an optiton:");
  }
  return 0;
}

void Init(sqlist &s1)
{
  s1.mylist = (Node *)malloc(100*sizeof(Node));
  s1.len = 0;
  s1.listsize = 100;
  return;
}
void Creat(sqlist &s1)
{
  s1.len = 0;
  cout<<"   how many numbers do you want to built:";
  scanf("%d",&n);
  cout<<"   please input their informations:"<<endl;
  for(int i=1;i<=n;i++)
  {
     printf("    input the %d person name:",i);
     scanf(" %s",s1.mylist[i-1].name);
     printf("    input the %d person phonenumber:",i);
     scanf(" %s",s1.mylist[i-1].number);
     s1.len++;
  }
  color(9);
  cout<<"   well done,the phonetxt has been created!!!"<<endl;
  color(14);
  return;
}

void Delet(sqlist &s1)
{
  cout<<"   please enter the number you want to delet:";
  heredelet:
  int x;
  scanf("%d",&x);
  if( x<1 || x>s1.len) 
  {
    color(4);
    cout<<"   sorry,your input is invalid,please input again:";
    color(14);
  goto heredelet;
  }

  struct Node *p,*q;
  p = &(s1.mylist[x-1]);
  q = s1.mylist + s1.len -1;
  for(++p;p<=q;++p) *(p-1) = *p;
  --s1.len;

  color(9);
  cout<<"   well done,the member has been deleted!!!"<<endl;
  color(14);
  return;
}
void Add(sqlist &s1)
{
  cout<<"   please enter the number you want to add:";
  hereadd:
  int x;
  scanf("%d",&x);
  if( x<1 || x>s1.len+1) 
  {
    color(4);
    cout<<"   sorry,your input is invalid,please input again:";
    color(14);
    goto hereadd;
  }

  struct Node cur;
  printf("    input the person name:");
  scanf(" %s",cur.name);
  printf("    input the person phonenumber:");
  scanf(" %s",cur.number);

  struct Node *p,*q;
  q = &(s1.mylist[x-1]);
  for(p=&(s1.mylist[s1.len-1]);p>=q;--p) *(p+1) = *p;
  *q = cur;
  ++s1.len;

  color(9);
  cout<<"   well done,the member has been added!!!"<<endl;
  color(14);
  return;
}
void Print(sqlist &s1)
{
  color(8);
  printf("    Name------phonenumber\n");

  struct Node *q = s1.mylist;
  for(q;q<s1.mylist+s1.len;q++)
  {
    printf("      %s    %s\n",q->name,q->number);
  }
  color(14);
  color(9);
  cout<<"   well done,the phonetxt is above!!!"<<endl;
  color(14);
  return;
}

void color(const unsigned short color1)
{    
  if(color1>=0&&color1<=15)
  SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), color1);
  else
  SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7);
  return;
}

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)建站jinyejixie.com,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。

網(wǎng)頁(yè)標(biāo)題:C語(yǔ)言使用順序表實(shí)現(xiàn)電話本功能-創(chuàng)新互聯(lián)
當(dāng)前地址:http://jinyejixie.com/article4/dehhie.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供動(dòng)態(tài)網(wǎng)站、網(wǎng)站策劃、網(wǎng)站建設(shè)App開(kāi)發(fā)、網(wǎng)站內(nèi)鏈、網(wǎng)站設(shè)計(jì)公司

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

微信小程序開(kāi)發(fā)
射洪县| 松潘县| 彝良县| 临武县| 武强县| 蛟河市| 霞浦县| 平凉市| 喜德县| 大邑县| 武穴市| 瑞安市| 元氏县| 峨眉山市| 鸡泽县| 离岛区| 洪雅县| 淮滨县| 宝清县| 普格县| 定襄县| 舞钢市| 泽普县| 乌审旗| 新安县| 津市市| 克拉玛依市| 文化| 永和县| 江北区| 酉阳| 浙江省| 随州市| 利津县| 梁山县| 安达市| 友谊县| 沙雅县| 富源县| 资溪县| 阿拉善左旗|