编了个21点游戏 结果错误好多的样子T T求指点

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int n1=2,n2=2;
int main()
{
    void Game();
    char str[10];
    printf("if you want to start the game,enter start,otherwise log out\n");
    gets(str);
    if(strcmp(str,"start")==0)
        Game();
    else printf("Thank you for your playing!\n");
    return 0;
}
void Game()
{
    void poker(int x);int analyse(int y);int count(int x,int y);
    void Decide(int player,int computer);int Analyse(int y);
    int computer,player,a1,a2,b1,,b2;
    while(n1<=5&&n2<=5)
    {
        a1=rand()%52+1;a2=rand()%52+1;
        b1=rand()%52+1;b2=rand()%52+1;
        poker(a1);poker(a2);
        a1=analyse(a1);a2=analyse(a2);
        b1=Analyse(b1);b2=Analyse(b2);
        player=count(a1,a2);computer=count(b1,b2);
        Decide(player,computer);
    }
}
void poker(int x)
{
    void heart(int x);void club(int x);
    void spade(int x);void diamond(int x);
    if(x>=1&&x<=13)
        heart(x);
    else if(x>=14&&x<=26)
        club(x);
    else if(x>=27&&x<=39)
        spade(x);
    else diamond(x);
}
void heart(int x)
{char m1=201,m2=187,m3=200,m4=188,m5=205,m6=186;
char p=3;
printf("%c%c%c\n",m1,m5,m2);
printf("%d",x);
printf("%c%c%c\n",m6,p,m6);
printf("%c%c%c\n",m3,m5,m4);
}
void club(int x)
{
char m1=201,m2=187,m3=200,m4=188,m5=205,m6=186;
char p=5;
if(x%13==0)
x=13;
else x=x%13;
printf("%c%c%c\n",m1,m5,m2);
printf("%d",x);
printf("%c%c%c\n",m6,p,m6);
printf("%c%c%c\n",m3,m5,m4);
}
void spade(int x)
{
char m1=201,m2=187,m3=200,m4=188,m5=205,m6=186;
char p=6;
if(x%13==0)
x=13;
else x=x%13;
printf("%c%c%c\n",m1,m5,m2);
printf("%d",x);
printf("%c%c%c\n",m6,p,m6);
printf("%c%c%c\n",m3,m5,m4);
}
void diamond(int x)
{
char m1=201,m2=187,m3=200,m4=188,m5=205,m6=186;
char p=4;
if(x%13==0)
x=13;
else x=x%13;
printf("%c%c%c\n",m1,m5,m2);
printf("%d",x);
printf("%c%c%c\n",m6,p,m6);
printf("%c%c%c\n",m3,m5,m4);
}
int analyse(int x)
{int choose(int p),m;
    x=x%13;
    if(x==1||x==11||x==12||x==0)
        m=choose(x);
    return m;
}
int Analyse(int x)
{int choose(int p),m;
    x=x%13;
    if(x==11||x==12||x==0)
    m=10;
    return m;
}
int choose(int x)
{
    int t,p;
    if(x==1)
    {printf("You can choose 1 or 11 to decide your score\n");
    scanf("%d",&t);
    p=t;}
    else p=10;
    return p;
}
int count(int x,int y)
{
    int t;
    if(x+y>21)
        t=0;
    else t=x+y;
    return t;
}
void Decide(int player,int computer)
{
    int mark1(int player);int mark2(int computer);
    void compare(int x,int y);
    char string[10];
    printf("your score is:%d",x);
    printf("If you want another poker,enter yes,otherwise no.\n");
    gets(string);
    if(strcmp(string,"yes")==0)
    {    player=mark1(player);
    computer=mark2(computer);
    Decide(player,computer);
    }
    else compare(player,computer);
}
int mark1(int player)
{void poker(int x);
int analyse(int x);
int count(int x,int y);
    int p;
    p=rand()%52+1;
    poker(p);
    p=analyse(p);
    player=count(player,p);
    n1++;
    return player;
}
int mark2(int computer)
{
    int analyse(int x);
int count(int x,int y);
    int t;
    if(computer<=15)
    {t=rand()%52+1;
    t=analyse(t);
    computer=count(computer,t);
    n2++;}
    return computer;
}
void compare(int x,int y)
{
    if(x>y)
        printf("You are the winner!congratulations!\n");
    else if(x==y)
        printf("this is a draw");
    else printf("I am sorry to tell you that you lose the game.");

}

时间: 2024-08-25 17:26:22

编了个21点游戏 结果错误好多的样子T T求指点的相关文章

用python实现自动玩Npubits的21点游戏

用python实现自动玩Npubits的21点游戏 21点的主页面 https://--- (此处不提供链接,用户直接在网站首页点击21点后,地址栏的链接便是.) 需要知道的关键点 (写代码时用来抓取数据的关键点) 1. 等待开局 若之前的21点还没有结束(暂时没有对手上线),那么不能开局,需等待之前的结束.若需等待,主页面包含以下内容 <button type="submit" class="btn btn-default">刷新</button

Javascript----实现21点游戏

1.效果 洗牌: 要牌: 亮牌: 2.代码 <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>21点游戏</title> <style type="text/css"> .container { width: 1080px; height: 600px; border: 1px solid #cccccc; mar

编绎显示Unknown type name &ldquo;CGFloat&rdquo; 错误解决方法

一.编绎显示Unknown type name "CGFloat"  错误解决方法   将Compile Sources As 改为 Objective-C 二.如果是extern const引起的.直接加头文件 #import <UIKit/UIKit.h>

21点游戏,命令行的,面像过程的写法。Ruby

21点游戏,命令行的,面像过程的写法. ruby 的写法以后再试试. # this is game 21 point # 操作命令符 空没有操作,n下一步,抽牌:w亮牌结束:l认输 $ope = '' $prompt = '>' $x1 = 0 $x2 = 0 $x3 = 0 $pc = 0 $u1 = 0 $u2 = 0 $u3 = 0 $over = '' def out_main(a = 0, b=0, c=0, pc = 0, us1=0, us2=0, us3=0) puts "

21点游戏

// 21点游戏 分为人机对战和人人对战 // 玩家每次抽一张牌 牌的点数为1-10点随机数 谁更接近21点谁就获胜 let readline = require("readline-sync"); // 清屏函数 let clear = () => process.stdout.write(process.platform === 'win32' ? '\x1Bc' : '\x1B[2J\x1B[3J\x1B[H'); // 抽牌函数 接收一个参数 玩家对象 let takeC

21点游戏java实现

21点的基本知识 21点是世界上比较流行的扑克游戏项目 除掉大小王的一副扑克牌,共计52张牌 21点不区分花色,其中A----10均代表扑克牌本身的点数J Q K代表10点 区分庄家和闲家,其中闲家可以优先要牌 而庄家在与闲家点数一样大的情况下,庄家赢,当有一方点数超过21点则另一方自动获胜,庄家的点数如果正好是21点,那么庄家直接获胜,其他情况以点数大的获胜 流程设计: 人机对战模式! 1由用户输入选择作庄还是作闲,电脑自动成为另一方 2随机为双方发两张牌 3询问闲家是否要牌,一直到闲家不再要

Jq之21点游戏

最近在看Jq,里面有个21点的游戏挺不错的,也是需要一点时间去理解~分享一下 html结构 <!DOCTYPE html> <html> <head> <title>Head First Black Jack</title> <meta http-equiv="Content-type" content="text/html;charset=utf-8"> <link href="

0当执行游戏xc000007b错误的解决方法

如图所示,这个错误是让很多玩家担心. 出现这个错误,可能是硬件的问题,也可能是软件的问题. 可是.因为硬件引起该问题的概率非常小,而且除了更换硬件之外没有更好的解决方法,因此本文将具体介绍怎样通过软件解决此问题,这也是大家最关心的. 大致介绍一下这个错误是怎样发生的. 这个错误的本意是提示内存错误,可是通常情况下并非内存存在问题,而是因为软件的问题产生了这个错误. 到底是什么软件的问题呢?答案是DirectX,而且多数情况下是DirectX 9.0的问题. 或许大家会问了:我玩的游戏都有Dire

自编的一款小游戏【比较蒟蒻】

直接上代码吧: #include<bits/stdc++.h> #include<windows.h> using namespace std; char P; int player,num=0,player1_e=0,player2_e=0,player1_d=0,player2_d=0,t=0,n1=0; int player1_m=0,player2_m=0,n2=0,true1=0,true2=0; void game();void shop();void home();v