来吧。。。。写了哥一个半小时。。。。终极版。。。
[mw_shl_code=c,true]#include <iostream>
#include <ctime>
#include <stdio.h>
#include <cstring>
#include <stdlib.h>
#include <conio.h>
#include <windows.h>
#include <dos.h>
using namespace std;
int jf;
void readd()
{
FILE *fp1;
fp1=fopen("data.dll","r");
fscanf(fp1,"%d",&jf);
fclose(fp1);
}
void writee()
{
FILE *fp2;
fp2=fopen("data.dll","w");
fprintf(fp2,"%d",jf);
fclose(fp2);
}
void start()
{
printf("*********************************************************************\n");
printf("* *\n");
printf("* 石头 剪刀 布 *\n");
printf("* *\n");
printf("* ver:1.0 作者:回遗未来 *\n");
printf("* *\n");
printf("* 欢迎访问www.aha-c.com论坛交流 *\n");
printf("*********************************************************************\n");
printf("\n\n\n\n是否需要打开官方论坛 www.aha-c.com?\n 1.Yes 2.No\n");
int a;
cin>>a;
if(a==1)
system("start http://www.aha-c.com/?fromuid=874");
system("cls");
cout<<"正在读取您的积分,请稍后.......\n";
readd();
cout<<"积分读取完毕,您的积分为"<<jf<<endl;
}
int main()
{
start();
string sr,shitou="石头",jiandao="剪刀",bu="布";
int a,b;
readd();
srand((unsigned)time( NULL ));
while(1)
{
while(1)
{
printf("\n\n请输入石头剪刀布参与游戏:\n",jf);
cin>>sr;
if((sr!=shitou) && (sr!=jiandao)&&(sr!=bu) )
{
system("CLS");
cout<<"输入错误,请重新输入\n";
}
else
break;
}
if(sr==shitou)
b=1;
if(sr==jiandao)
b=2;
if(sr==bu)
b=3;
a=rand()%1000; //0-333石头 333-666剪刀 666-999布
if(a<=333)
{
a=1;
cout<<"玩家:"<<sr<<" 电脑:"<<shitou<<endl;
if(b==1)
{
printf("啊哈,平局再来一盘吧~~\n");
printf("\\n\n\n\n\n\n 您的积分为%d\n",jf);
}
if(b==3)
{
cout<<"恭喜恭喜,胜利!\n积分+1";
jf++;
printf("\n\n\n\n\n\n\n 您的积分为%d\n",jf);
writee();
}
if(b==2)
{
cout<<"不要灰心,再来一盘!\n积分-1";
jf--;
printf("\n\n\n\n\n\n\n 您的积分为%d\n",jf);
writee();
}
}
if(a<=666 && a>333)
{
a=2;
cout<<"玩家:"<<sr<<" 电脑:"<<jiandao<<endl;
if(b==2)
{
printf("啊哈,平局再来一盘吧~~\n");
printf("\n\n\n\n\n\n\n 您的积分为%d\n",jf);
}
if(b==1)
{
cout<<"恭喜恭喜,胜利!\n积分+1";
jf++;
printf("\n\n\n\n\n\n\n 您的积分为%d\n",jf);
writee();
}
if(b==3)
{
cout<<"不要灰心,再来一盘!\n积分-1";
jf--;
printf("\n\n\n\n\n\n\n 您的积分为%d\n",jf);
writee();
}
}
if(a>666)
{
a=3;
cout<<"玩家:"<<sr<<" 电脑:"<<bu<<endl;
if(b==3)
{
printf("啊哈,平局再来一盘吧~~\n");
printf("\n\n\n\n\n\n\n 您的积分为%d\n",jf);
}
if(b==2)
{
cout<<"恭喜恭喜,胜利!\n积分+1";
jf++;
printf("\n\n\n\n\n\n\n 您的积分为%d\n",jf);
writee();
}
if(b==1)
{
cout<<"不要灰心,再来一盘!\n积分-1";
jf--;
printf("\n\n\n\n\n\n\n 您的积分为%d\n",jf);
writee();
}
}
}
return 0;
}
[/mw_shl_code]
哈哈 头晕吧。。。 |