| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 795 人关注过本帖
标题:关于数字游戏的到判断时不会了,求请教!
只看楼主 加入收藏
小强。小强
Rank: 2
来 自:山西大同
等 级:论坛游民
帖 子:42
专家分:56
注 册:2012-11-15
结帖率:100%
收藏
已结贴  问题点数:40 回复次数:14 
关于数字游戏的到判断时不会了,求请教!
程序代码:
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
void NumTochar();
void guess();
int rang();
void judge();
void print();
int main()
{
    int P,count;
    NumTochar();
    guess();
    rang();
    printf("previous points;%d\n",P);
    printf("\n Guess            Type            Number            Amont   \n");
    for(count=1;count<=5;count++)
    {
       judge();
       print();
    }
    return 0;
}

void NumTochar()//将相应的的数字用字母表示,底 L(1-12),中M(13-24),高H(25-36)左F(1-34)(每隔3个数,1,4,7,10,,,34),
//中C(2-35)(每隔3个数,2,5,,,35),右R(3-36)(每隔3个数,3,6,9,,36),所有数字N(1-36),O(1到36中的奇数),E(1到36中的偶数)
{
    char Type;
    int i;
    int l[11]={1,2,3,4,5,6,7,8,9,10,12};
    int m[12]={13,14,15,16,17,18,19,20,21,22,23,24};
    int h[12]={25,26,27,28,29,30,31,32,33,34,35,36};
    int f[12]={1,4,7,10,13,16,19,22,25,28,31,34};
    int c[12]={2,5,8,11,14,17,20,23,26,29,32,35};
    int r[12]={3,6,9,12,15,18,21,24,27,30,33,36};
    int b[36]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36};
    int o[18]={1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35};
    int e[18]={2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36};
    if(l[0]=1 && l[i]<=12)
        Type='L';
    if(m[0]=13 && m[i]<=24)
        Type='M';
    if(h[0]=25 && h[i]<=36)
        Type='H';
    if(f[0]=1&&f[i-1]+3&&f[i]<=34)
        Type='F';
    if(c[0]=2&&e[i-1]+3&&e[i]<=35)
        Type='C';
    if(r[0]=3&&r[i-1]+3&&r[i]<=36)
        Type='R';
    if(b[0]=1&&b[i]<=36)
        Type='N';
    if(o[0]=1&&o[i-1]+2&&o[i]<=35)
        Type='O';
    if(e[0]=2&&e[i-1]+2&&e[i]<=36)
        Type='E';

}

void guess()//猜测 高中底左中右奇偶或确切的数字
{
    int p,count,P,P1,i,b[36];
    char Type;
    printf("how many would you like; \n ");//开始将的分数
    scanf("%d",&P);
    printf("you can guess 5;\n");//5次机会
    for(count=1;count<=5;count++)
    {
        printf("enter you choice");//猜测
        scanf("%c",&Type);
        if(Type='N')
        {
            printf("enter you number;");//如果才确切的数字就请输入数字
            scanf("%d",&b[i]);
        }
      printf("points at risk;");//你押的分数
      scanf("%d",p);
      if(P<p)//如果押的分数大于给的分数则错误
      {
          printf("ERROR");
          printf("please enter at risk;");
          scanf("%d",&p);
          P1=P-p;
      }
    }

}

int rang()//产生随机数
{
    int rangNo,range;
    srand(time(NULL));
    range=36;
    rangNo=rand()%range+1;
    printf("my number is %d;\n",rangNo);
    return(rangNo);
}

/*
void judge()//进行判断,,,,,就这不会了!试了两种方法都错误
{
    int P0,P1,P,p,rangNo,i,Type,j;
    int l[12],m[12],h[12],f[12],c[12],r[12],b[36],o[18],e[18];   
        switch(rangNo)
      //for(j=1;j<=12;j++)
         case 1: if(Type=='L'&&Type='O'&&Type='F')     P0=P1+2*p;
         case 2: if(Type='L'&&type='E'&&type='C')     P0=P1+2*p;
         case 3: if(Type='L'&&type='O'&&type='R')     P0=P1+2*p; 
         case 4: if(Type='L'&&type='E'&&type='F')     P0=P1+2*p;
         case 5: if(Type='L'&&type='O'&&type='C')     P0=P1+2*p;
         case 6: if(Type='L'&&type='E'&&type='R')     P0=P1+2*p;
         case 7: if(Type='L'&&type='O'&&type='F')     P0=P1+2*p; 
         case 8: if(Type='L'&&type='E'&&type='C')      P0=P1+2*p;
         case 9: if(Type='L'&&type='O'&&type='R')     P0=P1+2*p;
         case 10:if(Type='L'&&type='E'&&type='F')     P0=P1+2*p;
         case 11: if(Type='L'&&type='O'&&type='C')     P0=P1+2*p;
         case 12: if(Type='L'&&type='E'&&type='R')     P0=P1+2*p;
         case 13: if(Type='M'&&type='O'&&type='F')     P0=P1+2*p;
         case 14: if(Type='M'&&type='E'&&type='C')     P0=P1+2*p;
         case 15: if(Type='M'&&type='O'&&type='R')     P0=P1+2*p;
         case 16: if(Type='M'&&type='E'&&type='F')     P0=P1+2*p;
         case 17: if(Type='M'&&type='O'&&type='C')     P0=P1+2*p;
         case 18: if(Type='M'&&type='E'&&type='R')     P0=P1+2*p;
         case 19: if(Type='M'&&type='O'&&type='F')     P0=P1+2*p;
         case 20: if(Type='M'&&type='E'&&type='C')     P0=P1+2*p;
         case 21: if(Type='M'&&type='O'&&type='R')     P0=P1+2*p;
         case 22: if(Type='M'&&type='E'&&type='F')     P0=P1+2*p;
         case 23: if(Type='M'&&type='O'&&type='C')     P0=P1+2*p;
         case 24: if(Type='M'&&type='E'&&type='R')     P0=P1+2*p;
         case 25: if(Type='H'&&type='O'&&type='F')     P0=P1+2*p;
         case 26: if(Type='H'&&type='E'&&type='C')     P0=P1+2*p;
         case 27: if(Type='H'&&type='O'&&type='R')     P0=P1+2*p;
         case 28: if(Type='H'&&type='E'&&type='F')     P0=P1+2*p;
         case 29: if(Type='H'&&type='O'&&type='C')     P0=P1+2*p;
         case 30: if(Type='H'&&type='E'&&type='R')     P0=P1+2*p;
         case 31: if(Type='H'&&type='O'&&type='F')     P0=P1+2*p;
         case 32: if(Type='H'&&type='E'&&type='C')     P0=P1+2*p;
         case 33: if(Type='H'&&type='O'&&type='R')     P0=P1+2*p;
         case 34: if(Type='H'&&type='E'&&type='F')     P0=P1+2*p;
         case 35: if(Type='H'&&type='O'&&type='C')     P0=P1+2*p;
         case 36: if(Type='H'&&type='E'&&type='R')     P0=P1+2*p;
*/



              /*if(Type='L')
                    P0=P1+2*p;
        case (m[i]=rangNo): if(Type='M')
                   P0=P1+2*p;
        case h[i]=rangNo: if(Type='H')
                   P0=P1+2*p;
        case f[i]=rangNo: if(Type='F')
                   P0=P1+2*p;
        case c[i]=rangNo: if(Type='C')
                   P0=P1+2*p;
        case r[i]=rangNo: if(Type='R')
                   P0=P1+2*p;
        case o[i]=rangNo: if (Type='O')
                   P0=P1+p;
        case e[i]=rangNo: if(Type='E')
                   P0=P1+p;
        case b[i]=rangNo: if(Type='E'&&rangNo==b[i])
                   P0=P1+36*p;
        default : printf("ERROR");
}*/


void print()//打印
{
    int count,b[36],p,i;
    char Type;
     printf("%d            %c            %d            %d",count,Type,b[i],p);
}


搜索更多相关主题的帖子: guess 游戏 count 
2012-12-17 15:11
daniel_
Rank: 5Rank: 5
等 级:职业侠客
帖 子:212
专家分:307
注 册:2012-11-13
收藏
得分:20 
楼主 完善一下你的需求先
2012-12-17 15:15
yaobao
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:蒙面侠
威 望:4
帖 子:1854
专家分:4121
注 册:2012-10-25
收藏
得分:6 
好长啊,  没看懂

认认真真的学习,踏踏实实的走路:戒骄戒躁!!!
2012-12-17 15:17
daniel_
Rank: 5Rank: 5
等 级:职业侠客
帖 子:212
专家分:307
注 册:2012-11-13
收藏
得分:0 
l[11]={1,2,3,4,5,6,7,8,9,10,12};
    int m[12]={13,14,15,16,17,18,19,20,21,22,23,24};
    int h[12]={25,26,27,28,29,30,31,32,33,34,35,36};
    int f[12]={1,4,7,10,13,16,19,22,25,28,31,34};
    int c[12]={2,5,8,11,14,17,20,23,26,29,32,35};
    int r[12]={3,6,9,12,15,18,21,24,27,30,33,36};
    int b[36]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36};
    int o[18]={1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35};
    int e[18]={2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36};
------------
数组最后需要有个位置写\0
so 建议你把数组定义的大点  明白
2012-12-17 15:17
小强。小强
Rank: 2
来 自:山西大同
等 级:论坛游民
帖 子:42
专家分:56
注 册:2012-11-15
收藏
得分:0 
回复 2楼 daniel_
到这个判断函数不会了void judge();不知道用啥方法
2012-12-17 15:18
daniel_
Rank: 5Rank: 5
等 级:职业侠客
帖 子:212
专家分:307
注 册:2012-11-13
收藏
得分:0 
/*if(Type='L')
---
这明显错了吧

if(Type == 'L')
2012-12-17 15:19
daniel_
Rank: 5Rank: 5
等 级:职业侠客
帖 子:212
专家分:307
注 册:2012-11-13
收藏
得分:0 
switch(rangNo)
      //for(j=1;j<=12;j++)
         case 1: if(Type=='L'&&Type='O'&&Type='F')     P0=P1+2*p;
         case 2: if(Type='L'&&type='E'&&type='C')     P0=P1+2*p;
         case 3: if(Type='L'&&type='O'&&type='R')     P0=P1+2*p;
         case 4: if(Type='L'&&type='E'&&type='F')     P0=P1+2*p;
         case 5: if(Type='L'&&type='O'&&type='C')     P0=P1+2*p;
         case 6: if(Type='L'&&type='E'&&type='R')     P0=P1+2*p;
         case 7: if(Type='L'&&type='O'&&type='F')     P0=P1+2*p;
         case 8: if(Type='L'&&type='E'&&type='C')      P0=P1+2*p;
-----------
switch()
{
    case:
        break;

}

一:
需要加个大括号吧,范围要明确
二:
每个case 后面要有个break 这是最基本的吧
2012-12-17 15:21
daniel_
Rank: 5Rank: 5
等 级:职业侠客
帖 子:212
专家分:307
注 册:2012-11-13
收藏
得分:0 
回复 5楼 小强。小强
你这个函数式用来干嘛的?
你先把你的整个题目要求 完整的明确的 讲一下
2012-12-17 15:22
小强。小强
Rank: 2
来 自:山西大同
等 级:论坛游民
帖 子:42
专家分:56
注 册:2012-11-15
收藏
得分:0 
回复 7楼 daniel_
sorry,有break没复制上,我写过==还是不行的!
2012-12-17 15:24
首席菜鸟官
Rank: 1
等 级:新手上路
帖 子:9
专家分:6
注 册:2012-12-17
收藏
得分:6 
能说明是做什么用的吗?
2012-12-17 15:25
快速回复:关于数字游戏的到判断时不会了,求请教!
数据加载中...
 
   



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

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