| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 512 人关注过本帖
标题:求大神帮助解答下该如何修改这个编程 T _T
只看楼主 加入收藏
青_城
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2014-7-8
结帖率:0
收藏
已结贴  问题点数:20 回复次数:4 
求大神帮助解答下该如何修改这个编程 T _T
#include <conio.h>   
#include <time.h>
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
#include<malloc.h>
#include<windows.h>
#define LEN sizeof(struct account)
struct account
{
         int account_num;        /* 账号 */
         char name[10];            /* 姓名 */
         char ID[20];            /* 身份证号码 */
         char phone[20];            /* 电话 */
         char password[10];         /* 密码 */
         char address[20];        /* 住址 */
         double money;           /* 余额 */
int b;
}acnt[1000];

int count;  /* 保存账户个数 */
void open_account (struct account *head)
{

FILE*fP;
head=NULL;
account *p1=NULL,*p2=NULL;

p1=( account*)malloc(sizeof(account));
printf("请输入您的姓名:");
scanf("%s",p1->name);

printf("请输入您的ID:");
scanf("%s",p1->ID);
  while(strlen(p1->ID)!=18)
{
   printf("请重新输入:");
   scanf("%s",p1->ID);
}


printf("请输入您的电话号码:");
scanf("%s",p1->phone);

printf("请输入您的地址:");
scanf("%s",p1->address);


printf("请输入您的密码:");
scanf("%s",p1->password);

 
     while(strlen(p1->password)!=6)
{
   printf("请重新输入:");
   scanf("%s",p1->password);
}   

{
     srand( time(NULL) );  
    p1->b= rand()%90000000 + 10000000*(rand()%9+1);  
    printf("\n");
    printf("卡号是:");
    printf("%d\n",p1->b);   
  
   
}
p1->money=0;
system("cls");
    printf("开户成功\n");
    printf("您的账号是:%d\n",p1->b);
    printf("您的密码是:%s\n",p1->password);
    printf("您的余额是:%f\n",p1->money);
    getch();
    if((fP=fopen("account_list","ab+"))==NULL)           /*打开文件*/
    {
        printf("cannot open file\n");
        return;
    }
    fprintf(fP,"%d%s%s%s%s%s%s%f",p1->account_num,p1->name,p1->ID,p1->phone,p1->address,p1->password,p1->money,p1->b);
    fclose(fP);

    return;
}
 
struct account *read()
{
    FILE *fp;
    struct account *head;
    struct account *p1,*p2;
    if((fp=fopen("account_list","rb"))==NULL)
    {
        fp=fopen("account_list","wb");
        return(NULL);
    }
    p1=p2=(struct account *)malloc(LEN);
    if(!feof(fp))
    {
        head=p1;
        fread(head,sizeof(struct account),1,fp);
    }
    else
    {
        return(NULL);
    }
    while(!feof(fp))
    {
        p2=p1;
        p1=(struct account *)malloc(LEN);
        fread(p1,sizeof(struct account),1,fp);
        p2->next=p1;
    }
    p2->next=NULL;
    fclose(fp);
    return(head);
}

struct account *login(struct account *head)
{
        struct account *p;
        char  b;
        char password[7];
        char flag=0;
      
    p=head;
    printf("\n\t\t请输入账号:  ");
    scanf("%s",b);
    while(flag!=1&&p!=NULL)
    {
        if(strcmp(b,p->b)!=0)
            p=p->next;
        else flag=1;
    }
    if(flag==1)
    {
        int i=0;

    system("cls");

    printf("\n\t\t请输入账号:  %s",b);
    printf("\n\t\t请输入密码:  ");
    password(password);
        if(strcmp(password,p->password)!=0)
{
        printf("密码输入错误!");
}
        else
        printf("登陆成功!");
}
return(p);
void cunkuan(struct account *p)
{
    int a;
    for(;;)
    {
        system("cls");
        printf("\n\t\t请输入存款金额:  ");
        scanf("%d",&a);
        p->count+=a;
        printf("\n\n\t\t\t存款成功!\n");
        printf("\n\t\t您的余额为%d元.\n",p->count);
void qu(struct account *p)
{
    int a;
    for(;;)
    {
        system("cls");
        printf("\n\t\t您目前的余额为%d元.\n",p->count);
        printf("\n\t\t请输入取款金额:  ");
        scanf("%d",&a);
        if(a<=(p->count))
        {
            p->count-=a;
            printf("\n\n\t\t\t取款成功!\n");
            printf("\n\t\t您目前的余额为%d元.\n",p->count);
        }
        else
            printf("\n\t\t对不起,您的余额已不足%d元.\n",a);
            break;
    }
}

void zhuanzhang(struct account *p1,struct account *head)
{
    struct account *p2;
    int flag=0;
    int b[20];
    int n;
    p2=head;

    system("cls");
    printf("\n\t\t请输入转入账号:  ");
    fflush(stdin);
    scanf("%s",b);
    while(flag!=1&&p2!=NULL)
    {
        if(strcmp(b,p2->b)!=0)
            p2=p2->next;
        else flag=1;
    }
    if(flag==1)
    {

            printf("\n\t\t您目前的余额为%d元.\n\n",p1->count);
        printf("\n\t\t请输入转账金额:  ");
        scanf("%d",&n);
        if(n<=(p1->count))
        {
            p1->count-=n;
            p2->count+=n;
            printf("\t\t转账成功!\n");
        }
        else
        {
            printf("\n\t\t您的余额已不足%d元,无法转账。\n",n);
             return;
}


void xgmm(struct account *p)
{
    int i;
    char *p1,password[6],password1[6],password2[6];
    p1=p->password;

    system("cls");
    printf("\n\n\t\t\t\t【修改密码】\n\n\n");
    printf("\n\n\t\t请输入旧密码:  ");
    password(password);
    if(strcmp(pasword,p1)!=0)
    {
        printf("\n\t\t密码输入错误,请重新输入!\n");
   
    }
    else
    {
        printf("\n\t\t请输入六位数的新密码:  ");
        password(password1);
        printf("\n\t\t请 再 次 输 入 密 码:  ");
        password(password2);
        if(strcmp(password1,password2)!=0)
        {
            printf("\t\t两次输入的密码不一致!\n");
            
        }
        else
        {
            
            for(i=0;password1[i]!='\0';i++)
            {
                p1[i]=password[i];
            }
            p1[i]='\0';
            printf("\n\n\t\t密码修改成功!\n");
            
        }
    }
}

void chaxun(struct account *p)
{
    system("cls");
    printf("\n\n\t\t您目前的余额为%d\n\n\t\t",p->count);
    system("pause");
   
}
void save(struct account *head)
{
    FILE *fp;
    struct account *p;
    if((fp=fopen("account_list","wb"))==0)
    {
        printf("cannot open file\n");
        return;
    }
    p=head;
    while(p!=NULL)
    {
        if(fwrite(p,sizeof(struct account),1,fp)!=1)
            printf("file write error\n");
        p=p->next;
    }
    fclose(fp);
}

void print_1()
{
 system("cls");
    printf("\n\n\n\n\n\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                                          \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                                          \n");
    printf("\t\t\t             版本 VI.0.0                 \n");
    printf("\t\t\t                                          \n");
    printf("\t\t\t                                          \n");
    printf("\t\t\t                            \n");
    printf("\n\n\n\n\n\n");
}


void print_2()
{
    system("cls");
    printf("\n\n");
    printf("\t\t≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈\n");
    printf("\t\t§                                             §\n");
    printf("\t\t§               服务类型                      §\n");
    printf("\t\t§                                             §\n");
    printf("\t\t§     1.存款                 4.转账           §\n");
    printf("\t\t§                                             §\n");
    printf("\t\t§     2.取款                 5.修改密码       §\n");
    printf("\t\t§                                             §\n");
    printf("\t\t§     3.查询                 6.退出           §\n");
    printf("\t\t§                                             §\n");
    printf("\t\t§                                             §\n");
    printf("\t\t§                                             §\n");
    printf("\t\t§                                             §\n");
    printf("\t\t§                                             §\n");
    printf("\t\t≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ \n");
    printf("\t\t                                                 \n");
   
}

int main(void)
{
    int server_type;

    WelcomeWindow();

    do{   
        MenuWindow();   
        scanf(" %d", &server_type);   //读取功能标号,根据标号选择不同的函数   
        fflush(stdin);   
        
        system("cls");   
        switch (server_type) {
        case 1:  
            /* 开户 */
            open_account(acnt);   
            break;               
        case 2:   
            /* 存款 */
           //eposit();   
            break;
        case 3:
            /* 取款 */
           //ithdraw();   
            break;               
        case 4:
            /* 转账 */
            //transfer();   
            break;
        case 5:
            /* 查询 */
           // inquiry();   
            break;
        case 6:
            /* 补卡 */
           // rpelsh_card();   
            break;
        case 7:
            /* 修改密码 */
          //  change_PIN();   
            break;
        case 8:
            /* 注销 */
            //logoff();
            break;
        case 0:
            /* 退出 */
            exit(1);   
        default:   
            printf("对不起,您所选的服务不存在!\n");   
        }   

      getch();                      //暂停功能(读取任意键继续)(conio.h)   
      system("cls");                //清除屏幕显示(stdlib.h)   
    } while(1);   
   
    return;
}

}
搜索更多相关主题的帖子: 身份证号码 password account address include 
2014-07-08 10:59
青_城
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2014-7-8
收藏
得分:0 
这是写一个银行系统的代码  有开户  转账 存款  取款  修改密码  查询这些功能的。敲完代码发现好多错   不知道该怎么改
2014-07-08 11:04
青_城
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2014-7-8
收藏
得分:0 
图片附件: 游客没有浏览图片的权限,请 登录注册
2014-07-08 11:04
青_城
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2014-7-8
收藏
得分:0 
help me    大神们       后天就要交作业了
2014-07-08 11:06
屌丝码农
Rank: 2
等 级:论坛游民
帖 子:1
专家分:20
注 册:2014-7-8
收藏
得分:20 
具体q我 313345307
2014-07-08 22:18
快速回复:求大神帮助解答下该如何修改这个编程 T _T
数据加载中...
 
   



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

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