| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2465 人关注过本帖
标题:大一刚学C语言求助
只看楼主 加入收藏
lwt19970329
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2016-9-5
收藏
 问题点数:0 回复次数:5 
大一刚学C语言求助
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#define N 5
struct user
{
    char ID_card[30];
    char user_card[10];
    char user_level[50];
    float add_money;    //充值
};
struct LinkList
{
    struct user struct_user;
    LinkList *pNext;
};
struct control
{
    char control_name[20];
    char control_password[15];
}control_person={"刘围天","19970329"};//管理员账户和密码设置
////////////////////////////////
void enter(int x);
void tab(int x);
void start();
void login();
void mainmenu();
void submenu1();
void submenu2();
void submenu3();
void submenu4();
void xian_shi(LinkList *pHead);
LinkList *adduser(LinkList *pHead);
LinkList *addmoney(LinkList *pHead);    //充值
LinkList *shang_wang(LinkList *pHead);    //上网
LinkList *zhu_xiao(LinkList *pHead);    //注销会员
void save(LinkList *pTemp);
LinkList *readsave();
void cha_xun_shen(LinkList *pHead);
void cha_xun_hui(LinkList *pHead);
/////////////////////
//启动
void start()
{
    system("cls");
    for(int k=0;k<2;k++)
    {
        
        
        for(int i=0;i<N;i++)
        {
            system("color B");
            enter(7);
            tab(3);
            printf("      围天网咖计费管理系统      ");
            enter(2);
            tab(4);
            printf("  ■");
            enter(1);
            tab(4);
            for(i=0;i<100000000;i++)
            {}
            system("cls");                    //circle 1 end
            
            enter(7);
            tab(3);
            printf("      围天网咖计费管理系统      ");
            enter(2);
            tab(4);
            printf("   ■");
            enter(1);
            tab(4);
            for(i=0;i<100000000;i++)
            {}
            system("cls");                    //circle 2 end
            
            enter(7);
            tab(3);
            printf("      围天网咖计费管理系统      ");
            enter(2);
            tab(4);
            printf("    ■");
            enter(1);
            tab(4);
            for(i=0;i<100000000;i++)
            {}
            system("cls");                    //circle 3 end        
            
            enter(7);
            tab(3);
            printf("      围天网咖计费管理系统      ");
            enter(2);
            tab(4);
            printf("     ■");
            enter(1);
            tab(4);            
            for(i=0;i<100000000;i++)
            {}
            system("cls");                    //circle 4 end
            
            enter(7);
            tab(3);
            printf("      围天网咖计费管理系统      ");
            enter(2);
            tab(4);
            printf("      ■");
            enter(1);
            tab(4);
            for(i=0;i<100000000;i++)
            {}
            system("cls");                    //circle 5 end
            
            enter(7);
            tab(3);
            printf("      围天网咖计费管理系统      ");
            enter(2);
            tab(4);
            printf("       ■");
            enter(1);
            tab(4);
            for(i=0;i<100000000;i++)
            {}
            system("cls");                    //circle 6 end
            
            enter(7);
            tab(3);
            printf("      围天网咖计费管理系统      ");
            enter(2);
            tab(4);
            printf("        ■");
            enter(1);
            tab(4);
            for(i=0;i<100000000;i++)
            {}
            system("cls");                    //circle 7 end
            
            enter(7);
            tab(3);
            printf("      围天网咖计费管理系统      ");
            enter(2);
            tab(4);
            printf("         ■");
            enter(1);
            tab(4);
            for(i=0;i<100000000;i++)
            {}
            system("cls");                    //circle 8 end
            
            enter(7);
            tab(3);
            printf("      围天网咖计费管理系统      ");
            enter(2);
            tab(4);
            printf("          ■");
            enter(1);
            tab(4);
            for(i=0;i<100000000;i++)
            {}
            system("cls");                    //circle 9 end
        }
    }
    login();
}
//登陆函数
void login()
{
    char name[20];
    char password[15];
    while(1)
    {
        system("cls");
        enter(7);
        tab(3);
        printf("             管理员登录      ");
        enter(2);
        tab(4);
        printf("Count:");
        fflush(stdin);
        if(strcmp(gets(name),control_person.control_name)==0)
        {
leap:       system("cls");
            enter(7);
            tab(3);
            printf("             管理员登录      ");
            enter(2);
            tab(4);
            printf("Password:");
            fflush(stdin);
            if(strcmp(gets(password),control_person.control_password)==0)
            {
                mainmenu();
                break;
            }
            else
            {
                char ch;
                tab(4);
                printf("Your password is error!\n");   
                tab(4);
                printf("Do you want to try again?(Y/N):");
                scanf("%c",&ch);
                if(ch=='Y' || ch=='y')
                    goto leap;
                else if(ch=='N' || ch=='n')
                    exit(0);
                else
                {
                    system("cls");
                    enter(7);
                    tab(1);
                    printf("Error!Please check your code then login again,thank you!\n");
                    tab(3);
                    exit(0);
                }
            }
        }

        else
        {
            char i;
            system("cls");
            enter(7);
            tab(4);
            printf("Your count is erorr!\n");
            tab(4);
            printf("Do you want to try again?(Y/N):");
            scanf("%c",&i);
            if(i=='Y' || i=='y')
                continue;
            else if(i=='N' || i=='n')
                exit(0);
            else
            {
                system("cls");
                enter(7);
                tab(1);
                printf("Error!Please check your code then login again,thank you!\n");
                tab(3);
                exit(0);
            }
        }
    }   
}
//enter函数
void enter(int x)
{
    for(int i=0;i<x;i++)
        printf("\n");
}
//tab函数
void tab(int x)
{
    for(int i=0;i<x;i++)
        printf("\t");
}
//mainmenu主菜单
void mainmenu()
{   
    struct LinkList *pHead=NULL;    //初始化
    while(1)
    {
        int i;
        system("cls");
        printf("\n\n\n\n\n\t\t\t********围天网咖计费管理系统*********\n");
        printf("\t\t\t**          1.注册会员             **\n");
        printf("\t\t\t**                                 **\n");
        printf("\t\t\t**          2.会员管理             **\n");
        printf("\t\t\t**                                 **\n");
        printf("\t\t\t**          3.注                **\n");
        printf("\t\t\t**                                 **\n");
        printf("\t\t\t**          4.重                **\n");
        printf("\t\t\t**                                 **\n");
        printf("\t\t\t**          5.关闭系统             **\n");
        printf("\t\t\t*************************************\n");
        printf("\t\t\t请选择:");
        fflush(stdin);         
        scanf("%d",&i);
        switch(i)
        {
        case 1:pHead=adduser(pHead);break;
        case 2:submenu1();break;
        case 3:login();break;
        case 4:start();break;
        case 5:submenu2();break;
        default:printf("输入错误!\n");for(int j=0;j<100000000;j++){}break;
        }
    }
}
//submenu1会员管理菜单
void submenu1()
{   
    struct LinkList *pHead=NULL;
    while(1)
    {
        int i;
        system("cls");
        printf("\n\n\n\n\n\t\t\t**************会员管理***************\n");
        printf("\t\t\t**         1.会员消费              **\n");
        printf("\t\t\t**                                 **\n");
        printf("\t\t\t**         2.注销会员              **\n");
        printf("\t\t\t**                                 **\n");
        printf("\t\t\t**         3.查找会员信息          **\n");
        printf("\t\t\t**                                 **\n");
        printf("\t\t\t**         4.查询所有会员信息      **\n");
        printf("\t\t\t**                                 **\n");
        printf("\t\t\t**         5.返回上一级菜单        **\n");
        printf("\t\t\t*************************************\n");
        printf("\t\t\t请选择:");
        fflush(stdin);
        scanf("%d",&i);
        switch(i)
        {
        case 1:submenu3();break;
        case 2:pHead=zhu_xiao(pHead);break;
        case 3:submenu4();break;
        case 4:;xian_shi(pHead);break;
        case 5:mainmenu();break;
        default:printf("输入错误!\n");for(int j=0;j<100000000;j++){}break;
        }

    }
}
//submenu2关闭系统
void submenu2()
{
   
    printf("\n\n\n\n\n\t\t\t********围天网咖计费管理系统*********\n");
    printf("\t\t\t**          谢谢您的使用!          **\n");
    printf("\t\t\t**                                 **\n");
    printf("\t\t\t**          欢迎再次使用!          **\n");
    printf("\t\t\t**                                 **\n");
    printf("\t\t\t** 技术支持:                       **\n");
    printf("\t\t\t**      http://disk.neusoft.**\n");
    printf("\t\t\t** 版权所有:                       **\n");
    printf("\t\t\t**      东软电子工程系集成3班刘围天**\n");
    printf("\t\t\t**              2016.08            **\n");
    printf("\t\t\t*************************************\n");
    exit(0);
}
//submenu3消费菜单
void submenu3()
{
    int i;
    LinkList *pHead=NULL;
    while(1)
    {
        system("cls");
        printf("\n\n\n\n\n\t\t\t**********消费内容*******************\n");
        printf("\t\t\t**          1.充值                 **\n");
        printf("\t\t\t**                                 **\n");
        printf("\t\t\t**          2.上网                 **\n");
        printf("\t\t\t**                                 **\n");
        printf("\t\t\t**          3.返回上一级菜单       **\n");
        printf("\t\t\t*************************************\n");
        printf("\t\t\t请选择:");
        fflush(stdin);
        scanf("%d",&i);
        switch(i)
        {
        case 1:pHead=addmoney(pHead);
            break;
        case 2:pHead=shang_wang(pHead);
            break;
        case 3:submenu1();break;
        default:
            printf("输入错误!请重新输入!\n");for(int j=0;j<100000000;j++){}break;
        }
    }
}
//submenu4会员查找函数
void submenu4()
{
    int i;
    LinkList *pHead=NULL;
    while(1)
    {
        system("cls");
        printf("\n\n\n\n\n\t\t\t**************查找会员***************\n");
        printf("\t\t\t**       1.按身份证号码查找        **\n");
        printf("\t\t\t**                                 **\n");
        printf("\t\t\t**       2.按会员卡号号码查找      **\n");
        printf("\t\t\t**                                 **\n");
        printf("\t\t\t**       3.返回上一级菜单          **\n");
        printf("\t\t\t*************************************\n");
        printf("\t\t\t请选择:");
        fflush(stdin);
        scanf("%d",&i);
        switch(i)
        {
        case 1:cha_xun_shen(pHead);
            break;
        case 2:
            cha_xun_hui(pHead);
            break;
        case 3:submenu1();break;
        default:
            printf("输入错误!请重新输入!\n");for(int j=0;j<100000000;j++){}break;
        }
    }
}
//新会员注册
LinkList *adduser(LinkList *pHead)
{
    LinkList *pTemp,*p;
    system("cls");
    pTemp=(LinkList *)malloc(sizeof(struct LinkList));
    if(pTemp==NULL)
        return pHead;
leap:
    printf("\n\n\n\n\t\t");
    printf("输入第二代身份证号码(18位):");
    fflush(stdin);
    gets(pTemp->struct_user.ID_card);
    for(int i=0;i<17;i++)
    {
        if(pTemp->struct_user.ID_card[i]>'9' || pTemp->struct_user.ID_card[i]<'0')  //如果输入的信息大于9小于0的范围(输入的不是数字)
        {
            system("cls");
            printf("输入的不是纯数字!\n请重新输入!\n");
            goto leap;   
        }
        else if(strlen(pTemp->struct_user.ID_card)!=18 || strlen(pTemp->struct_user.ID_card)==0)
        {
            system("cls");
            printf("输入不合法!\n请重新输入!\n");
            goto leap;
        }
    }
   
loop:
    printf("\n\t\t");
    printf("请输入卡号(8位):");
    fflush(stdin);
    gets(pTemp->struct_user.user_card);
    for(i=0;i<8;i++)
    {
        if(pTemp->struct_user.user_card[i]>'9' || pTemp->struct_user.user_card[i]<'0')  //如果输入的信息大于9小于0的范围(输入的不是数字)
        {
            system("cls");
            tab(3);
            printf("输入的不是纯数字!\n请重新输入!\n");
            goto loop;   
        }
        else if(strlen(pTemp->struct_user.user_card)!=8 || strlen(pTemp->struct_user.user_card)==0)
        {
            system("cls");
            printf("输入不合法!\n请重新输入!\n");
            goto loop;
        }
    }
k:    printf("\n\n\t\t|-----------会员优惠活动------------|\n");
    printf("\t\t|     普通会员  >0  <=10元          |\n");
    printf("\t\t|     铜卡会员  >10 <=20元 +10元    |\n");
    printf("\t\t|     银卡会员  >20 <=30元 +20元    |\n");
    printf("\t\t|     金卡会员  >30 <=50元 +30元    |\n");
    printf("\t\t|     VIP会员  充100元  送80元      |\n");
    printf("\t\t|-----------------------------------|\n");
    printf("\t\t");
    printf("充值:");
    fflush(stdin);
    scanf("%f",&(pTemp->struct_user.add_money));    //充值
    if(pTemp->struct_user.add_money>1000 || pTemp->struct_user.add_money<=0)  //如果输入的信息大于9小于0的范围(输入的不是数字)
    {
        system("cls");
        printf("输入错误!\n请重新输入!\n");
        goto k;   
    }
    else if(pTemp->struct_user.add_money>0 && pTemp->struct_user.add_money<=10)
    {
        tab(2);
        strcpy(pTemp->struct_user.user_level,"普通会员");
        printf("■恭喜你!你已成为本网咖普通会员!■\n");
        
    }
    else if(pTemp->struct_user.add_money>10 && pTemp->struct_user.add_money<=20)
    {
        tab(2);
        strcpy(pTemp->struct_user.user_level,"铜卡会员");
        printf("■恭喜你!你已成为本网咖铜卡会员!■\n");
        pTemp->struct_user.add_money+=10;
    }
    else if(pTemp->struct_user.add_money>20 && pTemp->struct_user.add_money<=30)
    {
        tab(2);
        strcpy(pTemp->struct_user.user_level,"银卡会员");
        printf("■恭喜你!你已成为本网咖银卡会员!■\n");
        pTemp->struct_user.add_money+=20;
    }
    else if(pTemp->struct_user.add_money>=30 && pTemp->struct_user.add_money<100)
    {
        tab(2);
        strcpy(pTemp->struct_user.user_level,"金卡会员");
        printf("■恭喜你!你已成为本网咖金卡会员!■\n");
        pTemp->struct_user.add_money+=30;
    }
    else if(pTemp->struct_user.add_money>=100)
    {
        tab(2);
        strcpy(pTemp->struct_user.user_level,"VIP会员");
        printf("■恭喜你!你已成为本网咖VIP会员!■\n");
        pTemp->struct_user.add_money+=80;
    }
    pTemp->pNext=NULL;
    //////////////////
    if(pHead==NULL)
        pHead=pTemp;
    else
    {
        p=pHead;
        while(p->pNext!=NULL)
            p=p->pNext;
        p->pNext=pTemp;
    }
    save(pTemp);
    return pHead;   
}
//保存会员注册
void save(LinkList *pTemp)  
{
    FILE *fp=fopen("user","ab");
    if(fp==NULL)
    {
        tab(3);
        printf("读取失败!\n");
        exit(0);
    }
    tab(3);
    printf("开始保存文件!\n");
    if(fwrite(pTemp,sizeof(struct LinkList),1,fp)==1)
    {
        tab(3);
        printf("文件保存成功!\n");
        getch();
    }
    else
    {
        tab(3);
        printf("文件保存失败!\n");
        getch();
    }
    fclose(fp);
}
//读取保存
LinkList *readsave()
{
    LinkList *pHead=NULL,*p;
    FILE *fp;
    fp=fopen("user","rb");
    if(fp==NULL)
    {
        tab(3);
        printf("文件打开失败!\n");
        getch();
        return pHead;
    }
    while(!feof(fp))
    {
        LinkList *pTemp=(LinkList*)malloc(sizeof(LinkList));
        int t=fread(pTemp,sizeof(struct LinkList),1,fp);
        pTemp->pNext=NULL;
        if(t>0)
        {
            if(pHead==NULL)
            {
                pHead=pTemp;
            }
            else
            {
                p=pHead;
                while(p->pNext!=NULL)
                    p=p->pNext;
                p->pNext=pTemp;
            }
        }
        else
            break;
    }
    fclose(fp);
    return pHead;
}
//显示所有会员信息
void xian_shi(LinkList *pHead)
{
    FILE *fp=fopen("user","rb");
    if(fp==NULL)
    {
        system("cls");
        printf("\n\n\n\n\n\n\n\n\t\t\t\t");
        printf("没有会员信息!\n");
        getch();
        return;
    }
    LinkList *pTemp,*p;
    pTemp=(LinkList *)malloc(sizeof(LinkList));
    int count=0;
    system("cls");
    enter(5);
    printf("     -----------------------|-------------|--------------|--------------\n");
    printf("\t身份证号码\t\t会员卡号\t卡上余额\t会员级别\n");
    printf("     -----------------------|-------------|--------------|--------------\n");
    while(!feof(fp))
    {   
        int t=fread(pTemp,sizeof(LinkList),1,fp);
        pTemp->pNext=NULL;
        //////////////////
        if(t>0)
        {
            count++;
            if(pHead==NULL)
            {
                pHead=pTemp;
            }
            else
            {
                p=pHead;
                while(p->pNext!=NULL)
                    p=p->pNext;
                p->pNext=pTemp;
            }
        }
        else   
        {   
            break;
        }
        printf("\t%-20s\t%-10s\t%-5.1f元\t\t%-6s\n",pTemp->struct_user.ID_card,pTemp->struct_user.user_card,pTemp->struct_user.add_money,pTemp->struct_user.user_level);            
    }
    printf("     -----------------------|-------------|--------------|--------------\n");
    printf("\n\t\t共有会员%d个\n",count);
    getch();
    fclose(fp);
}
//查找会员信息(按身份证号码查找)
void cha_xun_shen(LinkList *pHead)
{
    LinkList *pTemp;
    char shen_fen[100];
    system("cls");
    enter(9);
    tab(3);
    printf("身份证号码:");
    fflush(stdin);
    gets(shen_fen);
    if(strlen(shen_fen)!=18)
    {
        tab(3);
        printf("输入错误!\n");
        getch();
        return;
    }
    pHead=readsave();
    if(pHead==NULL)
    {
        tab(3);
        printf("没有找到会员信息或会员不存在!\n");
        getch();
        return;
    }   
    pTemp=pHead;
    while(pTemp)
    {
        if(strcmp(pTemp->struct_user.ID_card,shen_fen)==0)
        {
            system("cls");
            enter(5);
            printf("     -----------------------|-------------|--------------|--------------\n");
            printf("\t身份证号码\t\t会员卡号\t卡上余额\t会员级别\n");
            printf("     -----------------------|-------------|--------------|--------------\n");
            printf("\t%-20s\t%-10s\t%-5.1f元\t\t%-6s\n",pTemp->struct_user.ID_card,pTemp->struct_user.user_card,pTemp->struct_user.add_money,pTemp->struct_user.user_level);   
            printf("     -----------------------|-------------|--------------|--------------\n");
            getch();
            break;
        }
        pTemp=pTemp->pNext;
    }
}

//查找会员信息(按会员卡号查找)
void cha_xun_hui(LinkList *pHead)
{
    LinkList *pTemp;
    char shen_fen[100];
    system("cls");   
    enter(9);
    tab(3);
0     fflush(stdin);
    gets(shen_fen);
    if(strlen(shen_fen)!=8)
    {
        tab(3);
        printf("输入错误!\n");
        getch();
        return;
    }
    pHead=readsave();
    if(pHead==NULL)
    {
        tab(3);
        printf("没有找到会员信息或会员不存在!\n");
        getch();
        return;
    }
    pTemp=pHead;
    while(pTemp)
    {
        if(strcmp(pTemp->struct_user.user_card,shen_fen)==0)
        {
            system("cls");
            enter(5);
            printf("     -----------------------|-------------|--------------|--------------\n");
            printf("\t身份证号码\t\t会员卡号\t卡上余额\t会员级别\n");
            printf("     -----------------------|-------------|--------------|--------------\n");
            printf("\t%-20s\t%-10s\t%-5.1f元\t\t%-6s\n",pTemp->struct_user.ID_card,pTemp->struct_user.user_card,pTemp->struct_user.add_money,pTemp->struct_user.user_level);   
            printf("     -----------------------|-------------|--------------|--------------\n");
            getch();
            break;
        }
        pTemp=pTemp->pNext;
    }
}
//保存充值、注销和上网消费后的后的会员信息
void save_chong(LinkList *pHead)
{
    FILE *fp=fopen("user","wb");
    if(fp==NULL)
    {
        tab(3);
        printf("文件打开失败!\n");
        getch();
        return;
    }
    LinkList *pTemp;
    pTemp=pHead;
    if(pHead==NULL)
    {
        printf("没有找到会员信息!\n");
        getch();
        return;
    }
    printf("开始保存修改!\n");
    while(pTemp)
    {
        fwrite(pTemp,sizeof(LinkList),1,fp);
        pTemp=pTemp->pNext;
    }
    printf("保存成功!\n");
    getch();
    fclose(fp);
}
//充值
LinkList *addmoney(LinkList *pHead)
{
    LinkList *pTemp;
    char shen_fen[100];
    system("cls");   
    enter(9);
    tab(3);
    printf("卡号(8位):");
    fflush(stdin);
    gets(shen_fen);
    if(strlen(shen_fen)!=8)
    {
        tab(3);
        printf("输入错误!\n");
        getch();
        return pHead;
    }
    pHead=readsave();    //very important
    if(pHead==NULL)
    {
        tab(3);
        printf("没有找到会员信息或会员不存在!\n");
        getch();
        return pHead;
    }
    pTemp=pHead;
    while(pTemp)
    {
        if(strcmp(pTemp->struct_user.user_card,shen_fen)==0)
        {
            system("cls");
            enter(5);
            printf("     -----------------------|-------------|--------------|--------------\n");
            printf("\t身份证号码\t\t会员卡号\t卡上余额\t会员级别\n");
            printf("     -----------------------|-------------|--------------|--------------\n");
            printf("\t%-20s\t%-10s\t%-5.1f元\t\t%-6s\n",pTemp->struct_user.ID_card,pTemp->struct_user.user_card,pTemp->struct_user.add_money,pTemp->struct_user.user_level);   
            printf("     -----------------------|-------------|--------------|--------------\n");
            float m=pTemp->struct_user.add_money;
            printf("请输入充值金额:");
            scanf("%f",&(pTemp->struct_user.add_money));
            pTemp->struct_user.add_money+=m;
            save_chong(pHead);
            break;
        }
        pTemp=pTemp->pNext;
    }
    return pHead;
}
//上网
LinkList *shang_wang(LinkList *pHead)
{
    LinkList *pTemp;
    char shen_fen[100];
    system("cls");   
    enter(2);
    printf("\n\n\n\n\t\t\t**********网吧计费管理系统***********\n");
    printf("\t\t\t**      1.普通会员   3元/时        **\n");
    printf("\t\t\t**                                 **\n");
    printf("\t\t\t**      2.铜卡会员   2.5元/时      **\n");
    printf("\t\t\t**                                 **\n");
    printf("\t\t\t**      3.银卡会员   2元/时        **\n");
    printf("\t\t\t**                                 **\n");
    printf("\t\t\t**      4.金卡会员   1.5元/时      **\n");
    printf("\t\t\t**                                 **\n");
    printf("\t\t\t**      5.VIP会员    1元/时        **\n");
    printf("\t\t\t*************************************\n");
    printf("请输入会员卡号码(8位数字):");
    fflush(stdin);
    gets(shen_fen);   
    if(strlen(shen_fen)!=8)
    {
        tab(3);
        printf("输入错误!\n");
        getch();
        return pHead;
    }
    pHead=readsave();    //读取文件
    if(pHead==NULL)        //如果头指针为空,说明没有该链表
    {
        tab(3);
        printf("没有找到会员信息或会员不存在!\n");
        getch();
        return pHead;
    }
    pTemp=pHead;    //头指针不为空
    while(pTemp)    //访问节点
    {
        if(strcmp(pTemp->struct_user.user_card,shen_fen)==0)    //如果找到与输入的会员卡号相同
        {                                                        //则输出该会员信息
            printf("     -----------------------|-------------|--------------|--------------\n");
            printf("\t身份证号码\t\t会员卡号\t卡上余额\t会员级别\n");
            printf("     -----------------------|-------------|--------------|--------------\n");
            printf("\t%-20s\t%-10s\t%-5.1f元\t\t%-6s\n",pTemp->struct_user.ID_card,pTemp->struct_user.user_card,pTemp->struct_user.add_money,pTemp->struct_user.user_level);   
            printf("     -----------------------|-------------|--------------|--------------\n");
            float m=pTemp->struct_user.add_money;//上网前的卡上余额
            float time;
            printf("请输入上网时间(时):");
            fflush(stdin);
            scanf("%f",&time);
            if(strcmp(pTemp->struct_user.user_level,"普通会员")==0)    //按会员级别来管理
            {                                                        //每小时上网的费用
                pTemp->struct_user.add_money=m-3*time;    //上网后的卡上余额
                save_chong(pHead);    //保存修改后的内容
                break;
            }
            else if(strcmp(pTemp->struct_user.user_level,"铜卡会员")==0)
            {
                pTemp->struct_user.add_money=m-2.5f*time;
                save_chong(pHead);
                break;
            }
            else if(strcmp(pTemp->struct_user.user_level,"银卡会员")==0)
            {
                pTemp->struct_user.add_money=m-2*time;
                save_chong(pHead);
                break;
            }
            else if(strcmp(pTemp->struct_user.user_level,"金卡会员")==0)
            {
                pTemp->struct_user.add_money=m-1.5f*time;
                save_chong(pHead);
                break;
            }
            else if(strcmp(pTemp->struct_user.user_level,"VIP会员")==0)
            {
                pTemp->struct_user.add_money=m-1*time;
                save_chong(pHead);
                break;
            }
        }
        pTemp=pTemp->pNext;//指针指向下一个查找,直到找到满足上面条件为止
    }
    return pHead;
}
//注销会员
LinkList *zhu_xiao(LinkList *pHead)
{
    LinkList *pTemp,*p;
    char shen_fen[100];
    system("cls");   
    enter(9);
    tab(3);
    printf("卡号:");
    fflush(stdin);
    gets(shen_fen);   
    pHead=readsave();    //读取文件
    if(pHead==NULL)        //如果头节点为空,表示这条链表没有内容,或者没有这条链表
    {
        tab(3);
        printf("没有找到会员信息或会员不存在!\n");
        return pHead;
    }
    pTemp=pHead;    //指针指向头节点
    while(pTemp)//访问节点
    {
        if(strcmp(pTemp->struct_user.user_card,shen_fen)==0)//寻找要删除的会员卡号,找到后输出
        {
            system("cls");
            enter(5);
            printf("     -----------------------|-------------|--------------|--------------\n");
            printf("\t身份证号码\t\t会员卡号\t卡上余额\t会员级别\n");
            printf("     -----------------------|-------------|--------------|--------------\n");
            printf("\t%-20s\t%-10s\t%-5.1f元\t\t%-6s\n",pTemp->struct_user.ID_card,pTemp->struct_user.user_card,pTemp->struct_user.add_money,pTemp->struct_user.user_level);   
            printf("     -----------------------|-------------|--------------|--------------\n");
            char ch;
            printf("\n你要注销该会员吗?(Y/N)\n");
            scanf("%c",&ch);
            switch(ch)
            {
            case 'Y':
            case 'y':
                {
                    if(pTemp==pHead)    //如果要删除的是头节点
                    {
                        pHead=pTemp->pNext;    //把头节点指针指向第二个节点,并把头节点覆盖
                        printf("注销成功!\n");
                        getch();
                        break;
                    }
                    p=pHead;//不是头节点,把指针指向头节点
                    while(1)
                    {
                        if(p->pNext==pTemp)    //如果p的指针域指向找到的节点pTemp
                        {
                            p->pNext=pTemp->pNext;//则把pTemp的指针域指向的下一个节点付给p的指针域
                            printf("注销成功!\n");//删除成功
                            getch();
                            break;
                        }
                        p=p->pNext;//寻找p->pNext和要删除节点pTemp的交合
                    }
                }
                break;
            case 'N':
            case 'n':
                break;
            }
        }
        pTemp=pTemp->pNext;//寻找shen_fen和节点的交合
    }
    save_chong(pHead);
    system("cls");
    return pHead;
}
//主函数
void main()
{
        start();
        mainmenu();
}



求助这里的enter函数和tab函数什么意思啊,还有刚开始的i<100000000什么意思
搜索更多相关主题的帖子: control include 管理员 C语言 密码 
2016-09-05 09:35
默看
Rank: 1
等 级:新手上路
帖 子:22
专家分:0
注 册:2016-9-1
收藏
得分:0 
换行和空格函数,通过调用达到换行和空格作用。i那个不知道
2016-09-05 10:58
ehszt
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:40
帖 子:1745
专家分:3216
注 册:2015-12-2
收藏
得分:0 
i<100000000大概起个延时的作用,不过有专门延时的函数Sleep().
2016-09-05 11:03
平常心q
Rank: 7Rank: 7Rank: 7
等 级:黑侠
威 望:7
帖 子:120
专家分:550
注 册:2016-3-31
收藏
得分:0 
enter函数:每x个,换行;
tab函数:水平制表位(horizeontal tab),它的作用是将光标移到最接近8的倍数的位置,使得后面的输入从此开始。换句话说,如果所有的数据都紧跟在制表符后面输出。
2016-09-05 22:09
大漠苍穹
Rank: 1
等 级:新手上路
威 望:1
帖 子:11
专家分:0
注 册:2016-7-27
收藏
得分:0 
大一看这么长的程序,很晕吧
2016-09-09 23:09
linlulu001
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:贵宾
威 望:20
帖 子:944
专家分:4047
注 册:2016-4-13
收藏
得分:0 
for(i=0;i<100000000;i++),起到延迟的作用,这个延迟时间和计算机性能有点关系。
enter函数和tab函数用来输出换行符和水平制表符。
如果不想用这两个函数,直接将'\n'和'\t'打印出来也行。
2016-09-10 07:04
快速回复:大一刚学C语言求助
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.058735 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved