⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 servetable1.c

📁 银行管理系统
💻 C
字号:
/*这份代码经源码格式软件格式化过
     yang_hx@neusoft.com      */
#include<stdio.h>
#include<string.h>
#include<time.h>
#include<ctype.h>
#include<stdlib.h>
#define ok 1
#define false -1
typedef int status ;

typedef struct accoutMaker 
{
    char ch[13];
    //   账号的12前位
    long int lastNum ;
    //后几位
    int total ;
    //开户数                /
}
accoutMaker,*accoutMakerp ;
typedef struct accout 
{
    char name[20];
    //账号持有人姓名
    char ch[20];
    //账号
long int  totalMoney ;
    //钱数
    char id[19];
    //身份证号
    char passwords[7];
    int tag ;
    //账号密码
}
accout,*accoutp ;
void reverse(char s[])
{
    int i,j ;
    char k ;
    for(i=0,j=strlen(s)-1;i<j;i++,j--)
    {
        k=s[i];
        s[i]=s[j];
        s[j]=k ;
    }
}
void itoal(long int n,char s[])
{
    int i ;
    long int sign ;
    if((sign=n)<0)n=-n ;
    i=0 ;
    do 
    {
        s[i++]=n%10+'0' ;
    }
    while((n/=10)>0);
    if(sign<0)
    {
        s[i++]='-' ;
    }
    s[i]='\0' ;
    reverse(s);
}
status iniAccout()
{
    FILE*w,*wp ;
    accoutMaker init ;
    scanf("%s",init.ch);
    init.lastNum=3914583 ;
    init.total=0 ;
    w=fopen("systemAccout","wb");
    wp=fopen("personAccout","wb");
    fwrite(&init,sizeof(accoutMaker),1,w);
    fclose(w);
    return ok ;
}
//对系统的时间和初始账户进行处理;


status check(char*id,char*passwords)
{
    int i ;
    
    loop2 :
    {
        if((strlen(id)!=18)||(strlen(passwords)!=6))
        {
            printf("身份证号或是密码位数不合法\n");
            goto loop1 ;
        }
        for(i=0;i<18;i++)
        if(!isdigit(id[i]))
        {
            printf("身份证中有非法字符\n");
            goto loop1 ;
            break ;
        }
    }
    if(i==18)return ok ;
    loop1 :
    {
        printf("身份证号:\n");
        scanf("%s",id);
        printf("密码:\n");
        scanf("%s",passwords);
        goto loop2 ;
    }
    
}
status accMaker()
{
    FILE*wcr ;
    //创建个人纪录
    FILE*was ;
    //追加系统纪录
    FILE*rs ;
    //读系统账户纪录
    FILE*wpa ;
    int i ;
    //追加个人账户
    char name[20];
    char id[19];
    char passwords[7];
    long int temacc ;
    char tem[8];
    char temaccs[8];
    char fname[25];
    char data[60];
    struct tm*local ;
    time_t tm ;
    accoutMaker curr ;
    accout newAccout,temAccout ;
    char filetem[5]=
    {
        ".txt" 
    }
    ;
    printf("请依次输入姓名,身份证号,和密码\n身份证号,密码号的合法长度为18位和7位\n");
    printf("姓名:\n");
    scanf("%s",newAccout.name);
    printf("身份证号:\n");
    scanf("%s",newAccout.id);
    printf("密码:\n");
    scanf("%s",newAccout.passwords);
    newAccout.tag=1 ;
    //该账户可用当TAG=2时表示该账户被禁
    check(newAccout.id,newAccout.passwords);
    //对输入的信息进行验证
    rs=fopen("systemAccout","rb");
    fread(&curr,sizeof(accoutMaker),1,rs);
    fclose(rs);
    temacc=++curr.lastNum ;
    curr.total++;
    rs=fopen("systemAccout","wb");
    fwrite(&curr,sizeof(accoutMaker),1,rs);
    fclose(rs);
    itoal(temacc,temaccs);
    strcpy(newAccout.ch,curr.ch);
    strcat(newAccout.ch,temaccs);
    strcpy(fname,curr.ch);
    strcat(fname,temaccs);
    strcat(fname,filetem);
    wcr=fopen(fname,"a");
    tm=time(NULL);
    local=localtime(&tm);
    fprintf(wcr,"本账户于开户的日期是:%s用户名是:%s\n账户号:%s\nID号为:%s\n",asctime(local),newAccout.name,newAccout.ch,newAccout.id);
    fclose(wcr);
    was=fopen("systemRecording.txt","a");
    fprintf(was,"\n%s新开一账户\n用户名是:%s\n账户号:%s\n密码是%s\nID号%s\n",asctime(local),newAccout.name,newAccout.ch,newAccout.passwords,newAccout.id);
    fclose(was);
    wpa=fopen("personAccout","ab");
    newAccout.totalMoney=0 ;
    fwrite(&newAccout,sizeof(accout),1,wpa);
    fclose(wpa);
    wpa=fopen("personAccout","r");
    for(i=0;i<curr.total;i++)
    {
        fread(&temAccout,sizeof(accout),1,wpa);   printf("%s\n",temAccout.ch) ;
        
    }
    fclose(wpa);
    
    
    
    return ok ;
}

main()
{

    if(accMaker())printf("开户成功!\n");
    getch();
    
}























































⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -