搜索
查看: 3257|回复: 8
打印 上一主题 下一主题

C语言一天一练--28.august

[复制链接]
楼主
发表于 2012-8-31 13:11:28 | 显示全部楼层
很简单哒  俺高三 木有时间写 你写下撒
~~~
沙发
发表于 2012-8-31 23:08:46 | 显示全部楼层
来吧。。。。写了哥一个半小时。。。。终极版。。。

[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]


哈哈 头晕吧。。。
板凳
发表于 2012-9-3 20:52:01 | 显示全部楼层
heaventone 发表于 2012-9-3 18:33
目测是C++啊,这不是C语言的练习吗?AHAc也能编译C++???

不好意思  我习惯使用C++  我有时间 帮你换成C的  不过只是把一些输入输出换一下。。。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

广播台
特别关注
快速回复 返回顶部 返回列表