| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1132 人关注过本帖, 1 人收藏
标题:c语言如何修改密码!
只看楼主 加入收藏
zou159211047
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2008-11-12
收藏(1)
 问题点数:0 回复次数:0 
c语言如何修改密码!
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<time.h>
#include<conio.h>                             
void mainmenu();                //主菜单
void reg();                        //注册
void khfw();                    //客户服务    
void zzfw();                    //自助服务    
void getmoneynum();                //获取提款金额
void creditmoney();                //获取存款金额
void querymoney();                //查询余额
void hkmoney();                    //开户金额
void exit();                    //退出系统
void exchangepassword()    ;        //修改密码
//宏定义
int m=0;                        //money余额
char name[30];                    //用户名
char password[7];                //用户密码
int k;                             //开户金额
struct consumer
{
    char name[10];
    char password[10];
}con1,con2;

void mainmenu()
{
    while(1)
    {
        int x;
        printf("\n\n\n\n\n\n");
        printf("\t   ******************************************************\n");
        printf("\t   **                                                  **\n");
        printf("\t   **                                                  **\n");
        printf("\t   **                                                  **\n");
        printf("\t   **\t\t  欢迎进入使用ATM系统 v3.0\t       **\n");
        printf("\t   **                                                  **\n");
        printf("\t   **                                                  **\n");
        printf("\t   **                                                  **\n");
        printf("\t   ******************************************************\n");
        printf("\t\t\t\t1----客户服务\n");
        printf("\t\t\t\t2----用户注册\n");
        printf("\t\t\t\t3----退出系统\n\n\n\n\n\n\n\n\n\n\n\n");

        printf("请选择:\t\t");
        scanf("%d",&x);
        printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
        if(x==3) break;
        switch(x)
        {
            case 1:khfw();break;            
            case 2:reg();break;
        }
        printf("按任意键继续");
        getch();
        system("cls");
    }
}
void reg()
{
        printf("\n");
        printf("\t   ******************************************************\n");
        printf("\t   **                                                  **\n");
        printf("\t   **\t\t        欢迎加入我们       \t       **\n");
        printf("\t   **                                                  **\n");
        printf("\t   ******************************************************\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
        printf("请输入用户名:\t\t");
        scanf("%s",&con1.name);
        fflush(stdin);
        printf("请输入密码:\t\t");
        for(int j=0;j<7;j++)
        {
            con1.password[j]=getch();
            if(con1.password[j]=='\r')
            {
                break;
            }
            putchar('*');
        }
            printf("\n");
            hkmoney();
}
void hkmoney()
{
        printf("请输入开户金额:\t\t");
        scanf("%d",&k);
        if(k>=10)
        {
            printf("恭喜你!注册成功!请按任意键继续....");
            m=m+k;
        }
        else
        {
            printf("开户金额低于10元无法开户\n");    
            hkmoney();
        }    
        getch();
        system("cls");
        mainmenu();
}
void khfw()
{
    system("cls");
    printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
    printf("请输入用户名:\t\t");    
    fflush(stdin);
    gets(con2.name);
    printf("请输入密码:\t\t");
    for(int j=0;j<7;j++)
    {
        con2.password[j]=getch();
        if(con2.password[j]=='\r')
        {
            break;
        }
            putchar('*');
    }
        printf("\n");
        if(!strcmp(con1.name,con2.name)&&!strcmp(con1.password,con2.password))
        {
            printf("登陆成功!请按任意键继续....");
            getch();
            system("cls");
            zzfw();
        }
        else if(!strcmp(con1.name,con2.name))
        {
            printf("对不起,你用户名或密码输入有误!\n");
            printf("请重新输入:\t");
            getch();
            system("cls");
            khfw();
        }
        else
        {
            printf("对不起,你用户名或密码输入有误!");
            getch();
            system("cls");
            khfw();
        }

}


void zzfw()
{
    int a;
    printf("\t   ******************************************************\n");
    printf("\t   **                                                  **\n");
    printf("\t   **\t\t            客户服务           \t       **\n");
    printf("\t   **                                                  **\n");
    printf("\t   ******************************************************\n");
    printf("\t\t\t\t1----取款\n");
    printf("\t\t\t\t2----存款\n");
    printf("\t\t\t\t3----余额查询\n");
    printf("\t\t\t\t4----密码修改\n");
    printf("\t\t\t\t5----返回主界面\n");
    printf("\t\t\t\t6----退出系统\n\n\n\n\n\n\n\n\n\n\n\n\n");
    printf("请选择服务:\t");
    scanf("%d",&a);
    switch(a)
    {
        case 1:getmoneynum();break;            //取款
        case 2:creditmoney();break;            //存款
        case 3:querymoney();break;            //余额查询
        case 4:exchangepassword();break;    //密码修改
        case 5:mainmenu();break;            //返回主界面
        case 6:exit();break;                //退出
    }
}


void getmoneynum()
{
        int draw;
        printf("请输入你要提款的金额:\t");
        scanf("%d",&draw);
        m=m-draw;
        if(draw<0)
        {
            printf("输入不合法!请重新输入\n");
        }
        else if(m<draw)
                printf("你的余额不足!\n");
        else
        {
        
            printf("提款成功!你的余额为%d\n",m);      
        }
        printf("请按任意键返回上一层....");
        getch();
        system("cls");
        zzfw();
}
void creditmoney()
{
     int bank;    
     printf("请输入你要存款的金额:\t");
     scanf("%d",&bank);
     m=m+bank;
     if(bank<0)
     {
         printf("输入不合法!情重新输入\n");
     }
     else
     {

        printf("存款成功!你的余额为%d\n",m);      
     }
    printf("请按任意键返回上一层....");
    getch();
    system("cls");
    zzfw();     
}
void querymoney()
{
    printf("你的余额为%d元\n",m);
    printf("按任意键返回上一层....");
    getch();
    system("cls");
    zzfw();
}
void exchangepassword()    
{
    char newpassword[7];
    printf("请输入原密码:\t");
    fflush(stdin);
    scanf("%s",password);
    if(strcmp(con1.password,password))
    {
        printf("请输入新密码:\t");
        scanf("%c",&newpassword);
        password[7]=newpassword[7];
    }
    else
    {
        printf("对不起 你输入错误....请重新输入!");
        exchangepassword();
    }
}
void main()
{
    mainmenu();
}
void exit()
{
    system("cls");
    printf("\n\n\n\n\n\n");
    puts("\t\t\t********************************");
    puts("\t\t\t**        谢谢你的使用        **");
    puts("\t\t\t**             再见!          **");
    puts("\t\t\t********************************");
    getch();
    system("cls");
}
搜索更多相关主题的帖子: C语言 密码 
2008-11-12 20:59
快速回复:c语言如何修改密码!
数据加载中...
 
   



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

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