该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
#include "stdio.h"
#include "string.h"
#include "windows.h"
char reg_name[30]="",reg_pwd[10]="";
char on_name[30],on_pwd[10];
void regist()
{
system("pause");
system("cls");
printf("\n\n\t\t\t欢迎使用红包注册系统\n\n");
while(1)
{
printf("\t\t请输入用户名[不能大于10个字符]:");
scanf("%s",reg_name);
if(strlen(reg_name)<=10)
{
while(1)
{
printf("\n\t\t请输入密码[密码长度为八位]:");
scanf("%s",reg_pwd);
if(strlen(reg_pwd)==8)
{
printf("\n\n\t\t注册成功,您的用户名是%s,密码是%s\n\n",reg_name,reg_pwd);
break;
}
else
{
printf("\n\t\t密码的长度为%d,请重新输入\n",strlen(reg_pwd));
}
}
break;
}
else
{
printf("\n\t\t用户名的长度为%d,请重新输入\n\n",strlen(reg_name));
}
}
}
int judge()
{
if(strcmp(reg_name,"")==0&&strcmp(reg_pwd,"")==0)
{
printf("\n\n\t\t您尚未注册,请先注册!\n\n");
return 0;
}
else
{
return 1;
}
}
void dl()
{
int i;
system("pause");
system("cls");
printf("\n\n\t\t\t欢迎使用红包登录系统\n\n");
for(i=1; i<=3; i++)
{
printf("\t\t请输入用户名:");
scanf("%s",on_name);
printf("\n\t\t请输入密 码:");
scanf("%s",on_pwd);
if(strcmp(reg_name,on_name)==0&&strcmp(reg_pwd,on_pwd)==0)
{
printf("\n\n\t\t登录成功,欢迎使用红包系统\n\n");
break;
}
else
{
printf("\n\n\t\t登录失败,请重新登录,您还有%d次机会\n\n",3-i);
}
}
}
void main()
{
int id;
while(1)
{
system("pause");
system("cls");
printf("\n\n\t\t\t红包管理系统\n\n");
printf("\t\t\t1:注册\n");
printf("\t\t\t2:登录\n");
printf("\t\t\t0:退出\n\n");
printf("\t\t请选择功能编号:");
scanf("%d",&id);
switch(id)
{
case 1:
regist();
break;
case 2:
if(judge()==1)
{
dl();
}
break;
case 0:
exit(1);
break;
default:
printf("\n\t\t您输入的功能编号有误,请重新输入!\n");
}
}
}
void start()
{
system("color A");
while(1)
{
float a[25];
float total;
printf("\t\t\t欢迎使用红包分发系统\n\n\n");
printf("请输入红包的总额:\n");
scanf("%f",&total);
int num;
printf("请输入红包的个数:(1~20之间)\n");
scanf("%d",&num);
float min=0.01;
int i=0,j;
float t;
float MAX=0;
float safe_total=0;
float sum=0;
srand(time(NULL));
for(i=1;i
{
t=total/(num-i+1);
safe_total=t*2;
a[i]=(rand()%(int)(safe_total*100)+(int)min*100)/100.0+min;
total-=a[i];
sum+=a[i];
printf("\t\t第%d个红包有%0.2f元\n",i,a[i]);
if(a[i]>MAX)
{
MAX=a[i];
j=i;
}
}
a[i]=total;
printf("\t\t第%d个红包有%0.2f元\n\n\n\n",i,a[i]);
if(total>MAX)
{
printf("\t\t第%d个同学是运气王,抢到了0.2f元的金额\n\n\n",num,total);
}
else
{
printf("\t\t第%d个同学是运气王,抢到了%0.2f元的金额\n\n\n",j,MAX);
}
system("pause");
system("cls");
}
return 0;
}