| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 337 人关注过本帖
标题:帮忙看下代码出错在什么地方
只看楼主 加入收藏
bin1654
Rank: 2
等 级:论坛游民
帖 子:11
专家分:15
注 册:2009-7-8
结帖率:83.33%
收藏
已结贴  问题点数:20 回复次数:2 
帮忙看下代码出错在什么地方
ATM银行模拟系统
到2级菜单了输入什么都是叫我输入账号的  
请高手帮下忙
#include<stdio.h>
#include<time.h>
#include<windows.h>
#include<string.h>
struct hh
{
    int zh;
    char name[20];
    char pwd[20];
    int ye;
};
void cd();
void wait();
struct hh bc(struct hh uu[],int n);
int tc();
int dl(struct hh uu[],int n);
void cd2();
void cx(struct hh uu[],int n);
void atm(struct hh uu[], int n);
void ck(struct hh uu[],int n);
void main()
{
    int h;
    int count=1,e=0,k=0;
    struct hh uu[500]={{450105,"增班","14756",1000000}};
    do
    {
        system("cls");
        cd();
        scanf("%d",&h);
        switch(h)
        {
        case 1:
            uu[count]=bc(uu,count);
            count++;
            break;
        case 2:
            k=dl(uu,count);
            if(k!=-1&&k!=-2)
            {
                cd2();
                atm(uu,count);
            }
            break;
        case 3:
            e=tc();
            break;
        }
        system("pause");
    }while(e!=1);
}

void cd()
{
    printf("\t\tATM 自动取款机模拟系统\n");
    printf("\t\t1.新用户开户\n\t\t2.客户服务\n\t\t3.退出系统\n");
    printf("请输入你的选择:");
}

struct hh bc(struct hh uu[],int n)
{
    char ch[20];
    struct hh tt;
    printf("账号为:%d\n",uu[n-1].zh+1);
    tt.zh=uu[n-1].zh+1;
    printf("请输入用户名字:");
    scanf("%s",tt.name);
    do
    {
        printf("请输入用户密码:");
        scanf("%s",tt.pwd);
        if(strlen(tt.pwd)<=7)
        {
            printf("请在一次输入密码:");
            scanf("%s",ch);
            if(strcmp(tt.pwd,ch)==0)
            {
                printf("注册成功!\n");
                tt.ye=0;
                printf("余额为:%d\n",tt.ye);
                break;
            }
            else
            {
                printf("两次密码输入不一致!\n");
            }
        }
        else
        {
            printf("密码长度过长!\n");
        }
    }while(1);
    return tt;
}

int dl(struct hh uu[],int n)
{
    int h;
    char ch[10];
    printf("请输入账号:");
    fflush(stdin);
    scanf("%d",&h);
    for(int i=0;i<n;i++)
    {
        if(uu[i].zh==h)
        {
            printf("请输入密码:");
            fflush(stdin);
            scanf("%s",ch);
            if(strcmp(uu[i].pwd,ch)==0)
            {
                
                printf("登陆成功!\n");
                printf("请稍等!");
                wait();
                return i;
                
            }
            else
            {
                printf("密码错误!\n");
                return -2;

            }
            break;
        }
    }
    if(i==n)
    {
        printf("账号不存在!\n");
        return -1;
    }
}


int tc()
{
    char a;
    printf("是否要退出程序?y/n\n");
    fflush(stdin);
    scanf("%c",&a);
    if(a=='y'||a=='Y')
    {
        return 1;
    }
    else if(a=='n'||a=='N')
    {
        return 2;
    }
    else
    {
        printf("输入错误!");
        return 3;
    }
}
void cx(struct hh uu[],int n)
{
    int k=0;
    k=dl(uu,n);
    if(k!=-1&&k!=-2)
    {
        printf("余额为:%d\n",uu[n].ye);
    }

}
void ck(struct hh uu[],int n)
{
    int k=0;
    int h;
    k=dl(uu,n);
    if(k!=-1&&k!=-2)
    {
        printf("请存入数额(100倍数):");
        scanf("%d",&h);
        uu[n].ye=h;
        printf("请稍等!/n");
        wait();
        printf("存款成功!\n");
    }
}
void cd2()
{
    system("cls");
    printf("\t\t1.查询余额\n\t\t2.存款服务\n\t\t3.取款服务\n\t\t4.转账服务\n\t\t5.修改密码服务\n\t\t6.打印清单\n\t\t7.返回上级菜单\n");
    printf("请输入选择:");
}
void atm(struct hh uu[], int n)
{
    int pp;
    int e=0;
    do
    {
        fflush(stdin);
        scanf("%d",&pp);
        switch(pp)
        {
        case 1:
            cx(uu,n);
            break;
        case 2:
            ck(uu,n);
            break;
        case 3:
            break;
        case 4:
            break;
        case 5:
            break;
        case 6:
            break;
        case 7:
            e=tc();
            break;
        default:
            printf("输入错误!\n");
            break;
        }
    }while(e!=1);
}
void wait()
{
    int a=0,b=0;
    for(int i=0;i<5;)
    {
        a=(unsigned)time(NULL);
        if(a>b)
        {
            printf("!");
            b=a;
            i++;
        }
    }
}
搜索更多相关主题的帖子: 代码 
2009-07-27 01:08
bowenbu
Rank: 2
等 级:论坛游民
帖 子:8
专家分:30
注 册:2009-6-23
收藏
得分:20 
#include<stdio.h>
#include<time.h>
#include<windows.h>
#include<string.h>
struct hh
{
    int zh;
    char name[20];
    char pwd[20];
    int ye;
};
void cd();
void wait();
struct hh bc(struct hh uu[],int n);
int tc();
int dl(struct hh uu[],int n);
void cd2();
void cx(struct hh uu[],int n);
void atm(struct hh uu[], int n);
void ck(struct hh uu[],int n);
void main()
{
    int h;
    int count=1,e=0,k=0;
    struct hh uu[500]={{450105,"增班","14756",1000000}};
    do
    {
        system("cls");
        cd();
        scanf("%d",&h);
        switch(h)
        {
        case 1:
            uu[count]=bc(uu,count);
            count++;
            break;
        case 2:
            k=dl(uu,count);
            if(k!=-1&&k!=-2)
            {
                cd2();
                atm(uu,count);
            }
            break;
        case 3:
            e=tc();
            break;
        }
        system("pause");
    }while(e!=1);
}

void cd()
{
    printf("\t\tATM 自动取款机模拟系统\n");
    printf("\t\t1.新用户开户\n\t\t2.客户服务\n\t\t3.退出系统\n");
    printf("请输入你的选择:");
}

struct hh bc(struct hh uu[],int n)
{
    char ch[20];
    struct hh tt;
    printf("账号为:%d\n",uu[n-1].zh+1);
    tt.zh=uu[n-1].zh+1;
    printf("请输入用户名字:");
    scanf("%s",tt.name);
    do
    {
        printf("请输入用户密码:");
        scanf("%s",tt.pwd);
        if(strlen(tt.pwd)<=7)
        {
            printf("请在一次输入密码:");
            scanf("%s",ch);
            if(strcmp(tt.pwd,ch)==0)
            {
                printf("注册成功!\n");
                tt.ye=0;
                printf("余额为:%d\n",tt.ye);
                break;
            }
            else
            {
                printf("两次密码输入不一致!\n");
            }
        }
        else
        {
            printf("密码长度过长!\n");
        }
    }while(1);
    return tt;
}

int dl(struct hh uu[],int n)
{
    int h;
    char ch[10];
    int i;
    printf("请输入账号:");
    fflush(stdin);
    scanf("%d",&h);
    for(i=0;i<n;i++)
    {
        if(uu[i].zh==h)
        {
            printf("请输入密码:");
            fflush(stdin);
            scanf("%s",ch);
            if(strcmp(uu[i].pwd,ch)==0)
            {
               
                printf("登陆成功!\n");
                printf("请稍等!");
                wait();
                return i;
            }
            else
            {
                printf("密码错误!\n");
                return -2;

            }
            break;
        }
    }
    if(i==n)
    {
        printf("账号不存在!\n");
        return -1;
    }
    return 0;
}


int tc()
{
    char a;
    printf("是否要退出程序?y/n\n");
    fflush(stdin);
    scanf("%c",&a);
    if(a=='y'||a=='Y')
    {
        return 1;
    }
    else if(a=='n'||a=='N')
    {
        return 2;
    }
    else
    {
        printf("输入错误!");
        return 3;
    }
}
void cx(struct hh uu[],int n)
{
    int k=0;
    //k=dl(uu,n);
    //if(k!=-1&&k!=-2)
    //{
        printf("余额为:%d\n",uu[n].ye);
    //}

}
void ck(struct hh uu[],int n)
{
    int k=0;
    int h;
    //k=dl(uu,n);
    //if(k!=-1&&k!=-2)
    //{
        printf("请存入数额(100倍数):");
        scanf("%d",&h);
        uu[n].ye=h;
        printf("请稍等!\n");
        wait();
        printf("存款成功!\n");
    //}
}
void cd2()
{
    system("cls");
    printf("\t\t1.查询余额\n\t\t2.存款服务\n\t\t3.取款服务\n\t\t4.转账服务\n\t\t5.修改密码服务\n\t\t6.打印清单\n\t\t7.返回上级菜单\n");
    printf("请输入选择:");
}
void atm(struct hh uu[], int n)
{
    int pp;
    int e=0;
    do
    {
        fflush(stdin);
        scanf("%d",&pp);
        switch(pp)
        {
        case 1:
            cx(uu,n);
            break;
        case 2:
            ck(uu,n);
            break;
        case 3:
            break;
        case 4:
            break;
        case 5:
            break;
        case 6:
            break;
        case 7:
            e=tc();
            break;
        default:
            printf("输入错误!\n");
            break;
        }
    }while(e!=1);
}
void wait()
{
    int a=0,b=0;
    int i;
    for(i=0;i<5;)
    {
        a=(unsigned)time(NULL);
        if(a>b)
        {
            printf("!");
            b=a;
            i++;
        }
    }
}
2009-07-27 17:13
bowenbu
Rank: 2
等 级:论坛游民
帖 子:8
专家分:30
注 册:2009-6-23
收藏
得分:0 
输入2级菜单后
调用处理函数时,你都调用了dl(uu,n)方法
自己再看看
2009-07-27 17:15
快速回复:帮忙看下代码出错在什么地方
数据加载中...
 
   



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

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