这里是活动管理程序,代码还未写完,持续完善中,这里面的代码都是开源的,免费给大家。因为还未完成此题目,所以很多功能尚不能实现,还会有许多bug,我会在两个星期内完成该程序和debug。
目前已实现的功能有
1.注册账号
2.登录账号
3.找回密码
4.获取密码
5.注册密码
6.退出系统
7.初始化的菜单界面
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<ctype.h>
#include<limits>
#include<cmath>
#include<algorithm>
#include<stdlib.h>
#include<malloc.h>
#include<queue>
#include<list>
#include<vector>
#include<stack>
#include<time.h>
#include<conio.h>
#define ll long long
using namespace std;
typedef struct user
{
char user_ID[20],user_password[20];
char secret_protection[3][20];
char join_activity_name[3][100],create_activity_name[3][100];
int join_activity_number=0;
} NODE;
NODE user[100];
int ID_number=0;
bool search_secret();
bool change_secret();
bool Login_ID();
int create_secret_protection();
bool Register();
string getTime();
void menu_1();
void menu_end();
int main()//主函数
{
menu_1();
return 0;
}
void menu_end()
{
system("CLS");
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" 您已成功退出程序! "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" 欢迎您的再次使用,若有建议欢迎提出! "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" 感谢您的使用! "<<endl;
cout<<" "<<endl;
cout<<" 立于浮华之世,奏响天籁之音"<<endl;
cout<<endl;
cout<<" 掠夺的代价是失去最重要的记忆 "<<endl;
cout<<endl;
cout<<" 与最爱的人约定 "<<endl;
cout<<endl;
cout<<" 我拯救了世界,却忘却了你! "<<endl;
cout<<endl;
cout<<" 奈何王已乘风去,世间再无幻想乡。 "<<endl;
cout<<endl;
cout<<" 愿未来你能与重要的人再次重逢 "<<endl;
cout<<endl;
cout<<" daisuki "<<endl;
}
bool change_secret(int x)
{
while(1)
{
char input1[20],input2[20];
system("CLS");
cout<<" 请输入您的新密码(16位字符以内):";
fgets(input1,18,stdin);
cout<<" 请再次输入您的新密码:";
fgets(input2,18,stdin);
if(!strcmp(input2,input1))
{
strcpy(user[x].user_password,input1);
return 1;
}
else
{
cout<<" 您两次输入的密码不相同,请重新输入"<<'\n';
cout<<'\n';
cout<<" 请按任意键继续...";
getch();
continue;
}
}
}
bool search_secret()
{
system("CLS");
while(1)
{
int i=0;
char ID[20];
cout<<"请输入您的账号"<<endl;
fgets(ID,18,stdin);
for(i=0; i<ID_number; i++) //查找账号
if(!strcmp(user[i].user_ID,ID))
break;
if(i==ID_number)//账号不存在时
{
int cur;
cout<<endl;
cout<<" 您输入的账号不存在,请重新输入或注册账号"<<endl;
cout<<" 【1】重新输入"<<endl;
cout<<endl;
cout<<" 【2】注册账号"<<endl;
cout<<endl;
cout<<" 请输入您的操作:"<<endl;
cin>>cur;
getchar();
cout<<endl;
cout<<" 请按任意键进入下一操作..."<<endl;
getch();
if(cur==1)
{
system("CLS");
continue;
}
else if(cur==2)
{
system("CLS");
Register();
return 1;
}
}
else
{
while(1)
{
char input[3][20];
cout<<" 第一个问题:您最好的外国朋友叫什么名字?(16个字母以内) "<<endl;
cout<<" :";
fgets(input[0],18,stdin);
if(!strcmp(user[i].secret_protection[0],input[0]))
{
cout<<'\n';
cout<<" 答案正确!请进入下题作答"<<'\n';
}
else
{
cout<<" 答案错误,请重新输入"<<endl;
cout<<'\n';
cout<<" 请按任意键继续...."<<'\n';
getch();
system("CLS");
continue;
}
cout<<endl;
cout<<" 第二个问题:你喜欢的数字是多少?(16位数以内) "<<endl;
cout<<" :";
fgets(input[1],18,stdin);
if(!strcmp(user[i].secret_protection[1],input[1]))
{
cout<<'\n';
cout<<" 答案正确!请进入下题作答"<<'\n';
}
else
{
cout<<" 答案错误,请重新输入"<<endl;
cout<<'\n';
cout<<" 请按任意键继续...."<<'\n';
getch();
system("CLS");
continue;
}
cout<<endl;
cout<<" 第三个问题: 您的英文名字叫什么?(16个字母以内) "<<endl;
cout<<" :";
fgets(input[2],18,stdin);
if(!strcmp(user[i].secret_protection[2],input[2]))
{
cout<<'\n';
cout<<'\n';
cout<<" 恭喜您成功验证密保! "<<endl;
cout<<endl;
cout<<" 请选择接下来您想进行的操作";
cout<<endl;
cout<<" |--------------------------------------| "<<endl;
cout<<" | |"<<endl;
cout<<" | 【1】获取密码 |"<<endl;
cout<<" | |"<<endl;
cout<<" | 【2】修改密码 |"<<endl;
cout<<" | |"<<endl;
cout<<" | 【3】退出系统 |"<<endl;
cout<<" | |"<<endl;
cout<<" |--------------------------------------|"<<endl;
cout<<" 您的选择是:";
int a;
cin>>a;
getchar();
if(a==1)
{
cout<<'\n';
cout<<" 您的密码是:"<<user[i].user_password<<'\n';
cout<<'\n';
cout<<" 请按任意键返回初始页面...";
getch();
menu_1();
return 0;
}
else if(a==2)
{
if(change_secret(i))
{
cout<<'\n';
cout<<" 您已成功修改密码";
cout<<" 请按任意键返回初始页面...";
menu_1();
}
return 0;
}
else if(a==3)
{
menu_end();
return 0;
}
}
else
{
cout<<" 答案错误,请重新输入"<<endl;
cout<<'\n';
cout<<" 请按任意键继续...."<<'\n';
getch();
system("CLS");
continue;
}
}
}
}
}
bool Login_ID()//账号登录
{
system("CLS");
while(1)
{
bool flag=1;
int i=0;
cout<<endl;
cout<<endl;
cout<<endl;
cout<<endl;
cout<<endl;
char now_user_ID[20],now_user_password[20];
cout<<" 请输入账号"<<endl;
cout<<" :";
fgets(now_user_ID,16,stdin);
cout<<endl;
cout<<" 请输入密码"<<endl;
cout<<" :";
fgets(now_user_password,16,stdin);
for(i=0; i<ID_number; i++) //查找账号
if(!strcmp(user[i].user_ID,now_user_ID))
break;
if(i==ID_number)//账号不存在
{
int cur;
cout<<endl;
cout<<"您输出的账号不存在,请重新输入或注册账号"<<endl;
cout<<"【1】重新输入"<<endl;
cout<<endl;
cout<<"【2】注册账号"<<endl;
cout<<endl;
cout<<"请输入您的操作:"<<endl;
cin>>cur;
getchar();
cout<<'\n';
cout<<"请按任意键进入下一操作..."<<endl;
getch();
if(cur==1)
{
system("CLS");
continue;
}
else if(cur==2)
{
system("CLS");
Register();
return 1;
}
}
else//存在
{
if(!strcmp(user[i].user_password,now_user_password))
{
cout<<"恭喜您登录成功"<<endl;
cout<<endl;
cout<<"请按任意键进入程序中心"<<endl;
getch();
}
else
{
int cur;
cout<<"密码错误,请重新登录或找回密码"<<endl;
cout<<"【1】重新输入"<<endl;
cout<<endl;
cout<<"【2】找回密码"<<endl;
cout<<endl;
cout<<"请输入您的操作:"<<endl;
cin>>cur;
getchar();
cout<<endl;
cout<<"请按任意键进入下一操作..."<<endl;
getch();
if(cur==1)
{
system("CLS");
continue;
}
else
{
system("CLS");
search_secret();
}
}
}
}
}
int create_secret_protection()
{
cout<<" 第一个问题:您最好的外国朋友叫什么名字?(16个字母以内) "<<endl;
cout<<" :";
fgets(user[ID_number].secret_protection[0],18,stdin);
cout<<endl;
cout<<" 第二个问题:你喜欢的数字是多少?(16位数以内) "<<endl;
cout<<" :";
fgets(user[ID_number].secret_protection[1],18,stdin);
cout<<endl;
cout<<" 第三个问题: 您的英文名字叫什么?(16个字母以内) "<<endl;
cout<<" :";
fgets(user[ID_number].secret_protection[2],18,stdin);
cout<<endl;
cout<<" 恭喜您成功注册密保,我们将为您的账号保驾护航 "<<endl;
cout<<endl;
cout<<" 请按任意键继续...... "<<endl;
getch();
system("CLS");
}
bool Register()//注册账号
{
while(1)
{
bool is_created=false;//判断用户名是否被注册过
cout<<endl;
cout<<endl;
cout<<endl;
cout<<endl;
cout<<" 请输入长度不超过16位由英文和数字的用户名"<<endl;
cout<<" :";
fgets(user[ID_number].user_ID,16,stdin);
cout<<endl;
cout<<" 请输入长度不超过16位的密码"<<endl;
cout<<" :";
fgets(user[ID_number].user_password,16,stdin);
for(int i=0; i<ID_number; i++) //查找已有的账号,看用户名是否重复。
{
if(strcmp(user[i].user_ID,user[ID_number].user_ID)==0)
{
is_created=true;
break;
}
}
if(!is_created)
{
cout<<endl;
cout<<endl;
cout<<endl;
cout<<endl;
cout<<endl;
cout<<endl;
cout<<" 温馨提示,为了您的账户安全,您必须注册密保 "<<endl;
cout<<endl;
cout<<" 下面进入注册密保环节 "<<endl;
cout<<endl;
cout<<" 请按任意键进入下一环节...... "<<endl;
getch();
system("CLS");
create_secret_protection();
ID_number++;
cout<<endl;
cout<<endl;
cout<<endl;
cout<<endl;
cout<<" 恭喜您成功注册账号! "<<endl;
cout<<endl;
cout<<" 请选择接下来您想进行的操作";
cout<<endl;
cout<<" |--------------------------------------| "<<endl;
cout<<" | |"<<endl;
cout<<" | 【1】返回上一菜单 |"<<endl;
cout<<" | |"<<endl;
cout<<" | 【2】登录账号 |"<<endl;
cout<<" | |"<<endl;
cout<<" | 【3】退出系统 |"<<endl;
cout<<" | |"<<endl;
cout<<" |--------------------------------------|"<<endl;
cout<<'\n';
cout<<" 您的选择是:";
int a;
cin>>a;
getchar();
if(a==1)
{
menu_1();
return 0;
}
else if(a==2)
{
Login_ID();
return 0;
}
else if(a==3)
{
menu_end();
return 0;
}
}
else
{
cout<<endl;
cout<<" 改用户名已被注册 "<<endl;
cout<<endl;
cout<<" 请按任意键重新开始注册 "<<endl;
getch();
system("CLS");
}
}
}
string getTime()
{
time_t timep;
time (&timep); //获取time_t类型的当前时间
char tmp[64];
strftime(tmp, sizeof(tmp), "%Y-%m-%d %H:%M:%S",localtime(&timep) );//对日期和时间进行格式化
return tmp;
}
void menu_1()
{
int a;
string time = getTime();
cout<<"***********************************************************************************************************************"<<endl;
cout<<"* * * *"<<endl;
cout<<"* 当前的时间是:"<<time<<" * 欢迎来到LEO的活动管理系统 * *"<<endl;
cout<<"* * * *"<<endl;
cout<<"*********************************************** * *"<<endl;
cout<<"* |--------------------------------------| *"<<endl;
cout<<"* 关于本活动管理程序的内容如下 | 请选择您需要的服务 | *"<<endl;
cout<<"* | | *"<<endl;
cout<<"* 1.您可创建和删除活动 | 【1】账号登录 | *"<<endl;
cout<<"* | | *"<<endl;
cout<<"* 2.您可以查看和对参加的活动发表评论 | | 愿 你 在 *"<<endl;
cout<<"* | 【2】账号注册 | 未来 *"<<endl;
cout<<"* 3.您可以查看和参加正在征集的活动 | | 能 *"<<endl;
cout<<"* | | 与 重 要 的 人 *"<<endl;
cout<<"* 4.您可以注册和找回自己的账号 | 【3】密码找回 | 再次重逢 *"<<endl;
cout<<"* | | *"<<endl;
cout<<"* 5.该系统可以实现单词组合查询活动名 | | -------以上 *"<<endl;
cout<<"* | 【4】退出系统 | *"<<endl;
cout<<"* 6.该系统会自动统计参加人数和人员名单 | | *"<<endl;
cout<<"* | | *"<<endl;
cout<<"* 7.该系统完全免费,且会给您优质的体验 | 祝您活动愉快 | *"<<endl;
cout<<"* |--------------------------------------| *"<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" 您的选择是:";
cin>>a;
getchar();
if(a==1)
{
if(Login_ID())
{
}
else
{
cout<<"密码错误"<<endl;
}
}
else if(a==2)
{
system("CLS");
Register();
}
else if(a==3)
{
search_secret();
}
else if(a==4)
{
}
else
{
}
}