| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1475 人关注过本帖
标题:[原创]猜数字游戏
只看楼主 加入收藏
andyzhshg
Rank: 2
等 级:论坛游民
帖 子:111
专家分:20
注 册:2007-9-1
收藏
 问题点数:0 回复次数:17 
[原创]猜数字游戏

*/ --------------------------------------------------------------------------------------
*/ 出自: 编程中国 http://www.bc-cn.net
*/ 作者: andyzhshg
*/ 时间: 2007-9-1 编程论坛首发
*/ 声明: 尊重作者劳动,转载请保留本段文字
*/ --------------------------------------------------------------------------------------


/*这是一个模仿文曲星之类电子辞典上的猜数字游戏的小程序。
即由系统随即生成一个四位数字,然后由玩家输入四个自己猜测的数字,系统经判断给出你猜对了几个数字,包括数字大小和位置都与随机数相同的荷只有大小正确但位置不正确的。*/

//此程序在Bland C++ 6.0 下编译通过

//因为初学,所以显得很幼稚,多谢大家指教
//多谢7楼指点,声明语句中的numbercompare已改为numCompare
//我对这个程序进行了重写,详情请看“猜数字游戏重写版”,希望大家继续提出意见。

// NumberGuess.c

#include "stdio.h"
#include "stdlib.h"
#include "time.h"

#define CRAET_SEED_A 1000
#define CRAET_SEED_B 2000
#define CRAET_SEED_C 3000
#define CRAET_SEED_D 4000
#define RIGHT_0_PLACE_0 0
#define RIGHT_1_PLACE_0 1
#define RIGHT_2_PLACE_0 2
#define RIGHT_3_PLACE_0 3
#define RIGHT_4_PLACE_0 4
#define RIGHT_0_PLACE_1 5
#define RIGHT_1_PLACE_1 6
#define RIGHT_2_PLACE_1 7
#define RIGHT_3_PLACE_1 8
#define RIGHT_0_PLACE_2 9
#define RIGHT_1_PLACE_2 10
#define RIGHT_2_PLACE_2 11
#define RIGHT_0_PLACE_3 12
#define RIGHT_1_PLACE_3 13
#define RIGHT_0_PLACE_4 14
#define TRUE 1
#define FALSE 0

int main (void)

{

int rndProduce( int ); //随机生成四位数字
int dialog ( int, int, int, int ); //输入对话
int numCompare(int, int, int, int, int, int, int, int); //数值比较

int num1, num2, num3, num4;
int numGuess1, numGuess2, numGuess3, numGuess4, numBackD, numBackC;
int cnt1, cnt2, cnt3, cnt4;
int numRight, numPlace;
int goOnConfirm ;

printf ( "***********************************************************\n" );
printf ( "欢迎你玩猜数字游戏!\n" ) ;
printf ( "***********************************************************\n" );
printf ( "版本: 1.0\n作者: Andyzhshg\n制作日期: 2007.08.14\n" );
printf ( "***********************************************************\n" );

NEXT : num1 = rndProduce ( CRAET_SEED_A ) ;
num2 = rndProduce ( CRAET_SEED_B ) ;
num3 = rndProduce ( CRAET_SEED_C ) ;
num4 = rndProduce ( CRAET_SEED_D ) ;

//printf("%i %i %i %i \n",num1, num2, num3, num4 ); //测试语句


printf ( "***********************************************************\n" );
printf ( "系统已经生成了一个随机的四位数字\n" ) ;
HERE: printf("请输入你预测的四位数字(每输入一个数字按一次回车键):\n");
printf ( "***********************************************************\n" );
scanf("%i %i %i %i",&numGuess1, &numGuess2, &numGuess3, &numGuess4);

//printf("\n%i%i%i%i",numGuess1, numGuess2, numGuess3, numGuess4); //测试语句

numBackD = dialog(numGuess1, numGuess2, numGuess3, numGuess4);

if ( numBackD == 1 )
{
numBackC = numCompare(num1, num2, num3, num4, numGuess1, numGuess2, numGuess3, numGuess4);

if ( numBackC == RIGHT_0_PLACE_0 )
{
numRight = 0;
numPlace = 0;
}

if ( numBackC == RIGHT_1_PLACE_0 )
{
numRight = 1;
numPlace = 0;
}
if ( numBackC == RIGHT_2_PLACE_0 )
{
numRight = 2;
numPlace = 0;
}
if ( numBackC == RIGHT_3_PLACE_0 )
{
numRight = 3;
numPlace = 0;
}
if ( numBackC == RIGHT_4_PLACE_0 )
{
numRight = 4;
numPlace = 0;
}
if ( numBackC == RIGHT_0_PLACE_1 )
{
numRight = 0;
numPlace = 1;
}
if ( numBackC == RIGHT_1_PLACE_1 )
{
numRight = 1;
numPlace = 1;
}
if ( numBackC == RIGHT_2_PLACE_1 )
{
numRight = 2;
numPlace = 1;
}
if ( numBackC == RIGHT_3_PLACE_1 )
{
numRight = 3;
numPlace = 1;
}
if ( numBackC == RIGHT_0_PLACE_2 )
{
numRight = 0;
numPlace = 2;
}
if ( numBackC == RIGHT_1_PLACE_2 )
{
numRight = 1;
numPlace = 2;
}
if ( numBackC == RIGHT_2_PLACE_2 )
{
numRight = 2;
numPlace = 2;
}
if ( numBackC == RIGHT_0_PLACE_3 )
{
numRight = 0;
numPlace = 3;
}
if ( numBackC == RIGHT_1_PLACE_3 )
{
numRight = 1;
numPlace = 3;
}
if ( numBackC == RIGHT_0_PLACE_4 )
{
numRight = 0;
numPlace = 4;
}
printf ( "***********************************************************\n" );
printf ( "你猜测的数字中:\n有 %i 个位置和数值都正确,\n有 %i 个数值正确但位置不正确。\n", numRight, numPlace);
printf ( "***********************************************************\n" );
if ( numRight == 4 )
{
printf ( "恭喜你,你答对了!\n正确打案就是 %i %i %i %i \n",numGuess1, numGuess2, numGuess3, numGuess4);
printf ( "***********************************************************\n" );
printf ( "继续游戏吗? 继续请按1,退出请按2.\n" );
scanf ( "%i" , &goOnConfirm ) ;
printf ("\n") ;
printf ( "***********************************************************\n" );
if ( goOnConfirm == 1 )
goto NEXT ;
if ( goOnConfirm == 2 )
{
printf ( "***********************************************************\n" );
printf ( "感谢你玩本游戏,请按回车键退出。\n" );
printf ( "***********************************************************\n" );
}
getchar ( );

}
if ( numRight !=4 )
{
printf ( "***********************************************************\n" );
printf ( "还要继续吗?继续请按1,显示正确答案请按2。\n" );
scanf ( "%i" , &goOnConfirm ) ;
printf ("\n") ;
printf ( "***********************************************************\n" );
if ( goOnConfirm == 1 )
goto HERE;
if ( goOnConfirm == 2 )
{
printf ( "***********************************************************\n" );
printf ( "正确答案是: %i %i %i %i ,再接再厉哦!\n" , num1, num2, num3, num4 ) ;
printf ( "***********************************************************\n" );
printf ( "继续游戏吗? 继续请按1,退出请按2.\n" );
scanf ( "%i" , &goOnConfirm ) ;
printf ("\n") ;
printf ( "***********************************************************\n" );
if ( goOnConfirm == 1 )
goto NEXT ;
if ( goOnConfirm == 2 )
{
printf ( "***********************************************************\n" );
printf ( "感谢你玩本游戏,请按回车键退出。\n" );
printf ( "***********************************************************\n" );
}
getchar ( );

}

}


}
if ( numBackD == 2 )
goto HERE;

getchar();
return 0;
}


int rndProduce(int seedProduce)
{

float seed;

//种子的初始化,调用时间函数
srand( (unsigned)time( NULL ) + seedProduce );


seed=( (float)rand() ) / ( (float)RAND_MAX );

if (seed >= 0 && seed < 0.1)
return 0;
if (seed >= 0.1 && seed < 0.2)
return 1;
if (seed >= 0.2 && seed < 0.3)
return 2;
if (seed >= 0.3 && seed < 0.4)
return 3;
if (seed >= 0.4 && seed < 0.5)
return 4;
if (seed >= 0.5 && seed < 0.6)
return 5;
if (seed >= 0.6 && seed < 0.7)
return 6;
if (seed >= 0.7 && seed < 0.8)
return 7;
if (seed >= 0.8 && seed < 0.9)
return 8;
if (seed >= 0.9)
return 9;


}

int dialog ( int value1, int value2, int value3, int value4 )
{
int putin;
printf ( "***********************************************************\n" );
printf ("你输入的数字是: %i %i %i %i \n确认请按1,重新输入请按2\n",value1, value2, value3, value4);
printf ( "***********************************************************\n" );
scanf("%i",&putin);

if ( putin == 1 )
{
printf ( "***********************************************************\n" );
printf("你已经确认了你的输入值,它是 %i %i %i %i \n",value1, value2, value3, value4);
printf ( "***********************************************************\n" );
return 1;
}
if ( putin == 2 )
{
printf ( "***********************************************************\n" );
printf("你放弃了这组预测值:\n");
printf ( "***********************************************************\n" );
return 2;
}


}


int numCompare(int val_a1, int val_a2, int val_a3, int val_a4, int val_b1, int val_b2, int val_b3, int val_b4)
{
int place = 0, right = 0;
int check_a1 = TRUE, check_a2 = TRUE, check_a3 = TRUE, check_a4 = TRUE, check_b1 = TRUE, check_b2 = TRUE, check_b3 = TRUE, check_b4 = TRUE;


// 检查数字和位置都正确的数字个数
if ( check_a1 == TRUE && check_b1 == TRUE && val_a1 == val_b1 )
{
right = right +1 ;
check_a1 = FALSE ;
check_b1= FALSE ;
}

if ( check_a2 == TRUE && check_b2 == TRUE && val_a2 == val_b2 )
{
right = right +1 ;
check_a2 = FALSE ;
check_b2= FALSE ;
}
if ( check_a3 == TRUE && check_b3 == TRUE && val_a3 == val_b3 )
{
right = right +1 ;
check_a3 = FALSE ;
check_b3= FALSE ;
}
if ( check_a4 == TRUE && check_b4 == TRUE && val_a4 == val_b4 )
{
right = right +1 ;
check_a4 = FALSE ;
check_b4= FALSE ;
}


//检查数字正确但位置错误的数字个数

if ( check_a1 == TRUE )
{
if ( check_b2 == TRUE && val_a1 == val_b2 )
{
place = place + 1 ;
check_a1 = FALSE ;
check_b2 = FALSE ;
}
if ( check_b3 == TRUE && val_a1 == val_b3 )
{
place = place + 1 ;
check_a1 = FALSE ;
check_b3 = FALSE ;
}
if ( check_b4 == TRUE && val_a1 == val_b4 )
{
place = place + 1 ;
check_a1 = FALSE ;
check_b4 = FALSE ;
}
}

if ( check_a2 == TRUE )
{
if ( check_b1 == TRUE && val_a2 == val_b1 )
{
place = place + 1 ;
check_a2 = FALSE ;
check_b1 = FALSE ;
}
if ( check_b3 == TRUE && val_a2 == val_b3 )
{
place = place + 1 ;
check_a2 = FALSE ;
check_b3 = FALSE ;
}
if ( check_b4 == TRUE && val_a2 == val_b4 )
{
place = place + 1 ;
check_a2 = FALSE ;
check_b4 = FALSE ;
}
}

if ( check_a3 == TRUE )
{
if ( check_b1 == TRUE && val_a3 == val_b1 )
{
place = place + 1 ;
check_a3 = FALSE ;
check_b1 = FALSE ;
}
if ( check_b2 == TRUE && val_a3 == val_b2 )
{
place = place + 1 ;
check_a3 = FALSE ;
check_b2 = FALSE ;
}
if ( check_b4 == TRUE && val_a3 == val_b4 )
{
place = place + 1 ;
check_a3 = FALSE ;
check_b4 = FALSE ;
}
}

if ( check_a4 == TRUE )
{
if ( check_b1 == TRUE && val_a4 == val_b1 )
{
place = place + 1 ;
check_a4 = FALSE ;
check_b1 = FALSE ;
}
if ( check_b2 == TRUE && val_a4 == val_b2 )
{
place = place + 1 ;
check_a4 = FALSE ;
check_b2 = FALSE ;
}
if ( check_b3 == TRUE && val_a4 == val_b3 )
{
place = place + 1 ;
check_a4 = FALSE ;
check_b3 = FALSE ;
}
if ( check_b4 == TRUE && val_a4 == val_b4 )
{
place = place + 1 ;
check_a4 = FALSE ;
check_b4 = FALSE ;
}
}





if ( right == 0 && place == 0 )
return RIGHT_0_PLACE_0;
if ( right == 1 && place == 0 )
return RIGHT_1_PLACE_0;
if ( right == 2 && place == 0 )
return RIGHT_2_PLACE_0;
if ( right == 3 && place == 0 )
return RIGHT_3_PLACE_0;
if ( right == 4 && place == 0 )
return RIGHT_4_PLACE_0;
if ( right == 0 && place == 1 )
return RIGHT_0_PLACE_1;
if ( right == 1 && place == 1 )
return RIGHT_1_PLACE_1;
if ( right == 2 && place == 1 )
return RIGHT_2_PLACE_1;
if ( right == 3 && place == 1 )
return RIGHT_3_PLACE_1;
if ( right == 0 && place == 2 )
return RIGHT_0_PLACE_2;
if ( right == 1 && place == 2 )
return RIGHT_1_PLACE_2;
if ( right == 2 && place == 2 )
return RIGHT_2_PLACE_2;
if ( right == 0 && place == 3 )
return RIGHT_0_PLACE_3;
if ( right == 1 && place == 3 )
return RIGHT_1_PLACE_3;
if ( right == 0 && place == 4 )
return RIGHT_0_PLACE_4;

}


c5Gw8Wru.rar (16.05 KB) [原创]猜数字游戏


[此贴子已经被作者于2007-9-1 23:53:27编辑过]



4QOqmJ39.jpg (68.14 KB)
图片附件: 游客没有浏览图片的权限,请 登录注册
搜索更多相关主题的帖子: 数字游戏 电子辞典 文曲星 中国 STRONG 
2007-09-01 14:59
windflush
Rank: 3Rank: 3
等 级:新手上路
威 望:8
帖 子:886
专家分:0
注 册:2007-7-1
收藏
得分:0 
顶一个,不过用的宏好多阿。

2007-09-01 15:11
andyzhshg
Rank: 2
等 级:论坛游民
帖 子:111
专家分:20
注 册:2007-9-1
收藏
得分:0 
用宏主要是为了增加可读性

编程并快乐着
2007-09-01 15:12
冰的热度
Rank: 2
等 级:禁止访问
威 望:5
帖 子:404
专家分:0
注 册:2006-12-2
收藏
得分:0 
用了那么多的if,最好改成switch...case结构

科学是永恒之迷...... 我的博客http://blog..cn/u/1267727974 阅读我的blog,懂与不懂都是收获!
2007-09-01 15:15
冰的热度
Rank: 2
等 级:禁止访问
威 望:5
帖 子:404
专家分:0
注 册:2006-12-2
收藏
得分:0 

错了一个地方

int numberCompare(int, int, int, int, int, int, int, int); //数值比较

后面调用的函数是numCompare.名字不一样,把上面的名字中ber删掉就行了

修改后的代码如下:

#include "stdio.h"
#include "stdlib.h"
#include "time.h"

#define CRAET_SEED_A 1000
#define CRAET_SEED_B 2000
#define CRAET_SEED_C 3000
#define CRAET_SEED_D 4000
#define RIGHT_0_PLACE_0 0
#define RIGHT_1_PLACE_0 1
#define RIGHT_2_PLACE_0 2
#define RIGHT_3_PLACE_0 3
#define RIGHT_4_PLACE_0 4
#define RIGHT_0_PLACE_1 5
#define RIGHT_1_PLACE_1 6
#define RIGHT_2_PLACE_1 7
#define RIGHT_3_PLACE_1 8
#define RIGHT_0_PLACE_2 9
#define RIGHT_1_PLACE_2 10
#define RIGHT_2_PLACE_2 11
#define RIGHT_0_PLACE_3 12
#define RIGHT_1_PLACE_3 13
#define RIGHT_0_PLACE_4 14
#define TRUE 1
#define FALSE 0

int main (void)

{

int rndProduce( int ); //随机生成四位数字
int dialog ( int, int, int, int ); //输入对话
int numCompare(int, int, int, int, int, int, int, int); //数值比较

int num1, num2, num3, num4;
int numGuess1, numGuess2, numGuess3, numGuess4, numBackD, numBackC;
int cnt1, cnt2, cnt3, cnt4;
int numRight, numPlace;
int goOnConfirm ;

printf ( "***********************************************************\n" );
printf ( "欢迎你玩猜数字游戏!\n" ) ;
printf ( "***********************************************************\n" );
printf ( "版本: 1.0\n作者: Andyzhshg\n制作日期: 2007.08.14\n" );
printf ( "***********************************************************\n" );

NEXT : num1 = rndProduce ( CRAET_SEED_A ) ;
num2 = rndProduce ( CRAET_SEED_B ) ;
num3 = rndProduce ( CRAET_SEED_C ) ;
num4 = rndProduce ( CRAET_SEED_D ) ;

//printf("%i %i %i %i \n",num1, num2, num3, num4 ); //测试语句


printf ( "***********************************************************\n" );
printf ( "系统已经生成了一个随机的四位数字\n" ) ;
HERE: printf("请输入你预测的四位数字(每输入一个数字按一次回车键):\n");
printf ( "***********************************************************\n" );
scanf("%i %i %i %i",&numGuess1, &numGuess2, &numGuess3, &numGuess4);

//printf("\n%i%i%i%i",numGuess1, numGuess2, numGuess3, numGuess4); //测试语句

numBackD = dialog(numGuess1, numGuess2, numGuess3, numGuess4);

if ( numBackD == 1 )
{
numBackC = numCompare(num1, num2, num3, num4, numGuess1, numGuess2, numGuess3, numGuess4);

if ( numBackC == RIGHT_0_PLACE_0 )
{
numRight = 0;
numPlace = 0;
}

if ( numBackC == RIGHT_1_PLACE_0 )
{
numRight = 1;
numPlace = 0;
}
if ( numBackC == RIGHT_2_PLACE_0 )
{
numRight = 2;
numPlace = 0;
}
if ( numBackC == RIGHT_3_PLACE_0 )
{
numRight = 3;
numPlace = 0;
}
if ( numBackC == RIGHT_4_PLACE_0 )
{
numRight = 4;
numPlace = 0;
}
if ( numBackC == RIGHT_0_PLACE_1 )
{
numRight = 0;
numPlace = 1;
}
if ( numBackC == RIGHT_1_PLACE_1 )
{
numRight = 1;
numPlace = 1;
}
if ( numBackC == RIGHT_2_PLACE_1 )
{
numRight = 2;
numPlace = 1;
}
if ( numBackC == RIGHT_3_PLACE_1 )
{
numRight = 3;
numPlace = 1;
}
if ( numBackC == RIGHT_0_PLACE_2 )
{
numRight = 0;
numPlace = 2;
}
if ( numBackC == RIGHT_1_PLACE_2 )
{
numRight = 1;
numPlace = 2;
}
if ( numBackC == RIGHT_2_PLACE_2 )
{
numRight = 2;
numPlace = 2;
}
if ( numBackC == RIGHT_0_PLACE_3 )
{
numRight = 0;
numPlace = 3;
}
if ( numBackC == RIGHT_1_PLACE_3 )
{
numRight = 1;
numPlace = 3;
}
if ( numBackC == RIGHT_0_PLACE_4 )
{
numRight = 0;
numPlace = 4;
}
printf ( "***********************************************************\n" );
printf ( "你猜测的数字中:\n有 %i 个位置和数值都正确,\n有 %i 个数值正确但位置不正确。\n", numRight, numPlace);
printf ( "***********************************************************\n" );
if ( numRight == 4 )
{
printf ( "恭喜你,你答对了!\n正确打案就是 %i %i %i %i \n",numGuess1, numGuess2, numGuess3, numGuess4);
printf ( "***********************************************************\n" );
printf ( "继续游戏吗? 继续请按1,退出请按2.\n" );
scanf ( "%i" , &goOnConfirm ) ;
printf ("\n") ;
printf ( "***********************************************************\n" );
if ( goOnConfirm == 1 )
goto NEXT ;
if ( goOnConfirm == 2 )
{
printf ( "***********************************************************\n" );
printf ( "感谢你玩本游戏,请按回车键退出。\n" );
printf ( "***********************************************************\n" );
}
getchar ( );

}
if ( numRight !=4 )
{
printf ( "***********************************************************\n" );
printf ( "还要继续吗?继续请按1,显示正确答案请按2。\n" );
scanf ( "%i" , &goOnConfirm ) ;
printf ("\n") ;
printf ( "***********************************************************\n" );
if ( goOnConfirm == 1 )
goto HERE;
if ( goOnConfirm == 2 )
{
printf ( "***********************************************************\n" );
printf ( "正确答案是: %i %i %i %i ,再接再厉哦!\n" , num1, num2, num3, num4 ) ;
printf ( "***********************************************************\n" );
printf ( "继续游戏吗? 继续请按1,退出请按2.\n" );
scanf ( "%i" , &goOnConfirm ) ;
printf ("\n") ;
printf ( "***********************************************************\n" );
if ( goOnConfirm == 1 )
goto NEXT ;
if ( goOnConfirm == 2 )
{
printf ( "***********************************************************\n" );
printf ( "感谢你玩本游戏,请按回车键退出。\n" );
printf ( "***********************************************************\n" );
}
getchar ( );

}

}


}
if ( numBackD == 2 )
goto HERE;

getchar();
return 0;
}


int rndProduce(int seedProduce)
{

float seed;


//种子的初始化,调用时间函数
srand( (unsigned)time( NULL ) + seedProduce );


seed=( (float)rand() ) / ( (float)RAND_MAX );

if (seed >= 0 && seed < 0.1)
return 0;
if (seed >= 0.1 && seed < 0.2)
return 1;
if (seed >= 0.2 && seed < 0.3)
return 2;
if (seed >= 0.3 && seed < 0.4)
return 3;
if (seed >= 0.4 && seed < 0.5)
return 4;
if (seed >= 0.5 && seed < 0.6)
return 5;
if (seed >= 0.6 && seed < 0.7)
return 6;
if (seed >= 0.7 && seed < 0.8)
return 7;
if (seed >= 0.8 && seed < 0.9)
return 8;
if (seed >= 0.9)
return 9;


}

int dialog ( int value1, int value2, int value3, int value4 )
{
int putin;
printf ( "***********************************************************\n" );
printf ("你输入的数字是: %i %i %i %i \n确认请按1,重新输入请按2\n",value1, value2, value3, value4);
printf ( "***********************************************************\n" );
scanf("%i",&putin);

if ( putin == 1 )
{
printf ( "***********************************************************\n" );
printf("你已经确认了你的输入值,它是 %i %i %i %i \n",value1, value2, value3, value4);
printf ( "***********************************************************\n" );
return 1;
}
if ( putin == 2 )
{
printf ( "***********************************************************\n" );
printf("你放弃了这组预测值:\n");
printf ( "***********************************************************\n" );
return 2;
}


}


int numCompare(int val_a1, int val_a2, int val_a3, int val_a4, int val_b1, int val_b2, int val_b3, int val_b4)
{
int place = 0, right = 0;
int check_a1 = TRUE, check_a2 = TRUE, check_a3 = TRUE, check_a4 = TRUE, check_b1 = TRUE, check_b2 = TRUE, check_b3 = TRUE, check_b4 = TRUE;


// 检查数字和位置都正确的数字个数
if ( check_a1 == TRUE && check_b1 == TRUE && val_a1 == val_b1 )
{
right = right +1 ;
check_a1 = FALSE ;
check_b1= FALSE ;
}

if ( check_a2 == TRUE && check_b2 == TRUE && val_a2 == val_b2 )
{
right = right +1 ;
check_a2 = FALSE ;
check_b2= FALSE ;
}
if ( check_a3 == TRUE && check_b3 == TRUE && val_a3 == val_b3 )
{
right = right +1 ;
check_a3 = FALSE ;
check_b3= FALSE ;
}
if ( check_a4 == TRUE && check_b4 == TRUE && val_a4 == val_b4 )
{
right = right +1 ;
check_a4 = FALSE ;
check_b4= FALSE ;
}


//检查数字正确但位置错误的数字个数

if ( check_a1 == TRUE )
{
if ( check_b2 == TRUE && val_a1 == val_b2 )
{
place = place + 1 ;
check_a1 = FALSE ;
check_b2 = FALSE ;
}
if ( check_b3 == TRUE && val_a1 == val_b3 )
{
place = place + 1 ;
check_a1 = FALSE ;
check_b3 = FALSE ;
}
if ( check_b4 == TRUE && val_a1 == val_b4 )
{
place = place + 1 ;
check_a1 = FALSE ;
check_b4 = FALSE ;
}
}

if ( check_a2 == TRUE )
{
if ( check_b1 == TRUE && val_a2 == val_b1 )
{
place = place + 1 ;
check_a2 = FALSE ;
check_b1 = FALSE ;
}
if ( check_b3 == TRUE && val_a2 == val_b3 )
{
place = place + 1 ;
check_a2 = FALSE ;
check_b3 = FALSE ;
}
if ( check_b4 == TRUE && val_a2 == val_b4 )
{
place = place + 1 ;
check_a2 = FALSE ;
check_b4 = FALSE ;
}
}

if ( check_a3 == TRUE )
{
if ( check_b1 == TRUE && val_a3 == val_b1 )
{
place = place + 1 ;
check_a3 = FALSE ;
check_b1 = FALSE ;
}
if ( check_b2 == TRUE && val_a3 == val_b2 )
{
place = place + 1 ;
check_a3 = FALSE ;
check_b2 = FALSE ;
}
if ( check_b4 == TRUE && val_a3 == val_b4 )
{
place = place + 1 ;
check_a3 = FALSE ;
check_b4 = FALSE ;
}
}

if ( check_a4 == TRUE )
{
if ( check_b1 == TRUE && val_a4 == val_b1 )
{
place = place + 1 ;
check_a4 = FALSE ;
check_b1 = FALSE ;
}
if ( check_b2 == TRUE && val_a4 == val_b2 )
{
place = place + 1 ;
check_a4 = FALSE ;
check_b2 = FALSE ;
}
if ( check_b3 == TRUE && val_a4 == val_b3 )
{
place = place + 1 ;
check_a4 = FALSE ;
check_b3 = FALSE ;
}
if ( check_b4 == TRUE && val_a4 == val_b4 )
{
place = place + 1 ;
check_a4 = FALSE ;
check_b4 = FALSE ;
}
}


if ( right == 0 && place == 0 )
return RIGHT_0_PLACE_0;
if ( right == 1 && place == 0 )
return RIGHT_1_PLACE_0;
if ( right == 2 && place == 0 )
return RIGHT_2_PLACE_0;
if ( right == 3 && place == 0 )
return RIGHT_3_PLACE_0;
if ( right == 4 && place == 0 )
return RIGHT_4_PLACE_0;
if ( right == 0 && place == 1 )
return RIGHT_0_PLACE_1;
if ( right == 1 && place == 1 )
return RIGHT_1_PLACE_1;
if ( right == 2 && place == 1 )
return RIGHT_2_PLACE_1;
if ( right == 3 && place == 1 )
return RIGHT_3_PLACE_1;
if ( right == 0 && place == 2 )
return RIGHT_0_PLACE_2;
if ( right == 1 && place == 2 )
return RIGHT_1_PLACE_2;
if ( right == 2 && place == 2 )
return RIGHT_2_PLACE_2;
if ( right == 0 && place == 3 )
return RIGHT_0_PLACE_3;
if ( right == 1 && place == 3 )
return RIGHT_1_PLACE_3;
if ( right == 0 && place == 4 )
return RIGHT_0_PLACE_4;


}


科学是永恒之迷...... 我的博客http://blog..cn/u/1267727974 阅读我的blog,懂与不懂都是收获!
2007-09-01 15:23
windflush
Rank: 3Rank: 3
等 级:新手上路
威 望:8
帖 子:886
专家分:0
注 册:2007-7-1
收藏
得分:0 
这个函数用的参数真多,8个~~
记得有个参考就是说最多参数8个,不过用这么多实在不理想。

2007-09-01 15:27
冰的热度
Rank: 2
等 级:禁止访问
威 望:5
帖 子:404
专家分:0
注 册:2006-12-2
收藏
得分:0 

你这跟本不是随机数呀,

答案永远是2 3 4 5,

太坑人了吧!


科学是永恒之迷...... 我的博客http://blog..cn/u/1267727974 阅读我的blog,懂与不懂都是收获!
2007-09-01 15:27
冰的热度
Rank: 2
等 级:禁止访问
威 望:5
帖 子:404
专家分:0
注 册:2006-12-2
收藏
得分:0 
大家输入
2
3
4
5
包你永远正确!!!!


科学是永恒之迷...... 我的博客http://blog..cn/u/1267727974 阅读我的blog,懂与不懂都是收获!
2007-09-01 15:30
killer_l
Rank: 2
等 级:新手上路
威 望:3
帖 子:1139
专家分:0
注 册:2007-5-25
收藏
得分:0 
原创那是要支持的........

2007-09-01 15:56
雨中飞燕
Rank: 3Rank: 3
等 级:禁止访问
威 望:8
帖 子:2200
专家分:0
注 册:2007-8-9
收藏
得分:0 
代码写得太长,没必要写的这么复杂,楼主的数组功底要练一下




by 雨中飞燕 QQ:78803110 QQ讨论群:5305909

[url=http://bbs.bc-cn.net/viewthread.php?tid=163571]请大家不要用TC来学习C语言,点击此处查看原因[/url]
C/C++算法习题(OnlineJudge):[url]http://yzfy.org/[/url]
2007-09-01 16:05
快速回复:[原创]猜数字游戏
数据加载中...
 
   



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

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