| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 604 人关注过本帖
标题:c语言,银行小游戏问题,请进看看!!
只看楼主 加入收藏
dreameameae
Rank: 1
等 级:新手上路
帖 子:11
专家分:4
注 册:2011-1-29
结帖率:50%
收藏
已结贴  问题点数:5 回复次数:3 
c语言,银行小游戏问题,请进看看!!
1:是否可以在输入帐号密码前面设计一个计时器,在30秒内输入不正确就退出程序,需要怎样的知识,代码和条件呢?
2:是否可以实现保存方法,即当第一次进入程序,存额有100000,存入5000,退出程序,下一次进入程序,存额为105000,意思是可以保存上一次的操作??
3:是否可以不用goto语句,书上都讲goto语句会破坏程序本身。
4:是否可以用注册的方式来注册帐号和密码,下一次进入程序是使用注册过帐号和密码进行登录,需要怎样的知识,代码和条件呢?
5:我想向服务器,游戏,系统,程序员方面的兴趣学习,我需要怎样的知识,需要学习那些?
6:请各位大侠注明解析,不性感激!!!!!
#include<stdio.h>
#include<conio.h>//银行小游戏
#include<ctype.h>
#include<stdlib.h>
int main(void)
{char zhanghao[4]="luo";char number[4];
int mima=12345;long monney=100000,monney_ru=0;
int password,xuanze,one=0,two=0,i=0;
while(number!=zhanghao&&password!=mima)/*判断帐号密码是否正确 */
{if(i>=3)
{printf("请输入正确的帐号和密码。");
getch();
return 0;}
 printf("请输入你的帐号:");
scanf("%s",&number);
printf("请输入你的密码:");
scanf("%d",&password);
i++;
if(number!=zhanghao&&password!=mima)
printf("密码或帐号错误,你还有%d次机会。\n",3-i);
else
printf("正确。");
}
system("cls");
loop:printf("欢迎来到XX银行,请选择:\n1:取款\n2:存款\n3:查询佘额\n4:退出\n");
printf("请输入:");
scanf("%d",&xuanze);
system("cls");
switch(xuanze)
{
              loop1:case 1:printf("请选择你要取的金额:\n1:50\n2:100\n3:200\n4:输入\n5:返回\n");
              printf("请输入:");
              scanf("%d",&one);
              system("cls");
              if(one==1)
              {
                        monney-=50;
              monney_ru=50;
              }
              else if(one==2)
              {
                   monney-=100;
              monney_ru=100;
              }
              else if(one==3)
              {
                   monney-=200;
              monney_ru=200;
              }
              else if(one==4)
              {
                   printf("请输入:");
              scanf("%d",&monney_ru);
              if(monney_ru>(monney-1))
              {
                                      printf("\n输入错误!!\n");
              goto loop1;
              }
              else
              monney-=monney_ru;
              }
              else if(one==5)
              goto loop;
              printf("\n成功取出%d元。",monney_ru);
              goto loop1;
              break;
             loop2: case 2:printf("\n请选择你要存的金额:\n1:50\n2:100\n3:200\n4:输入\n5:返回\n");
             printf("请输入:");
              scanf("%d",&two);
              system("cls");
              if(two==1)
              {monney+=50;
              monney_ru=50;}
              else if(two==2)
              {monney+=100;
              monney_ru=100;}
              else if(two==3)
             { monney+=200;
              monney_ru=200;}
              else if(two==4)
              {printf("请输入:");
              scanf("%d",&monney_ru);
              monney+=monney_ru;}
              else if(two==5)
              goto loop;
              printf("\n成功存入%d元。\n\n",monney_ru);
              goto loop2;
              break;
              case 3:printf("\n你的佘额为¥:%d\n\n",monney);
              goto loop;
              break;
              case 4:break;
              default:printf("错误!!\n");break;}
              
              
getch();
}
搜索更多相关主题的帖子: 小游戏 服务器 程序员 计时器 c语言 
2011-01-29 21:32
刘定邦
Rank: 10Rank: 10Rank: 10
等 级:青峰侠
帖 子:687
专家分:1570
注 册:2010-9-21
收藏
得分:2 
看一看..
2011-01-29 21:54
点线面
Rank: 8Rank: 8
来 自:NO.-1
等 级:蝙蝠侠
帖 子:525
专家分:980
注 册:2011-1-3
收藏
得分:2 
看楼主给的程序,估计楼主还在入门,系统方面选择C语言或者C++方向没有错,不过在你没有编程基础的时候,C语言不是入门首选,因为你还没有培养书写格式,高级语言最重要之一就可读性,但从你给我们看代码,可读性并不是很好,这不方便我们阅读,所以先培养书写格式,起码有助于大家学习提高。C语言太灵活对不注意可读性的人来说,写出来代码,只有自己明白,别人看一头汗水,就算自己写,N年之后维护带来不方便,更不用说相互学习,提高水平。等你有“格式概念”学C或C++也不迟。

小代码,大智慧
2011-01-29 23:48
zzgzzg00
Rank: 7Rank: 7Rank: 7
等 级:黑侠
威 望:2
帖 子:388
专家分:627
注 册:2010-8-2
收藏
得分:2 
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
void menu();
void bulid();
void log();
/*void rebuld();
void money();*/
void quit();
struct money{
char number[10];
char password[10];
long money;
}tempt;
void menu()
{
char ch;
printf("1.bulid a number\n");
printf("2.log in the number\n");
printf("3.rebulid the password\n");
printf("4.rebulid the money\n");
printf("5.exit\n");
ch=getch();
clrscr();
switch(ch)
{
case'1':bulid();break;
case'2':log();break;
/*case'3':rebulid();break;
case'4':money();break;*/
case'5':quit();break;
default:
{
clrscr();
menu();
}
break;
}
}
void bulid()
{
char c;
FILE *fp,*dp;
if((fp=fopen("number.dat","a+b"))==NULL)
printf("error");
while(1)
{
printf("please input the number:\n");
gets(tempt.number);
flushall();
printf("please input the password:\n");
gets(tempt.password);
flushall();
tempt.money=10000;
fwrite(&tempt,sizeof(tempt),1,fp);
printf("do you want to bulid another?'y'or'n'");
c=getch();
if(c=='n')
break;
}
clrscr();
menu();
fclose(fp);
/*if((dp=fopen("number.dat","rb"))==NULL)
printf("error");
while(fread(&tempt,sizeof(tempt),1,fp)==1)
{
printf("%s\n",tempt.number);
printf("%s\n",tempt.password);
printf("%ld\n",tempt.money);
}*/
}
void log()
{
char a[20],b[20];
int i=1;
FILE *fp;
if((fp=fopen("number.dat","rb"))==NULL)
printf("error");
printf("please input the number:\n");
gets(a);
flushall();
printf("please input the password\n");
gets(b);
flushall();
while(fread(&tempt,sizeof(tempt),1,fp)==1)
{
if((strcmp(a,tempt.number)==0)&&(strcmp(b,tempt.password)==0))
{
printf("you have $%ld\n",tempt.money);
i=0;
break;
}
}
if(i==1)
printf("wrong number or password\n");
printf("press any key to back");
getch();
clrscr();
menu();
}
void quit()
{
exit(0);
}
main()
{
clrscr();
menu();
}
呵呵 没弄完,只能实现创建帐号和登录 不怎么好 见笑

粗心是大敌
2011-01-30 10:49
快速回复:c语言,银行小游戏问题,请进看看!!
数据加载中...
 
   



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

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