编程C语言 24点游戏

2.1 功能需求<br />计算机能随机生成四个某范围的4个整数(或者用户输入4个整数),如果有解,则输出所有不同的解;如果没解,则输出一个小于24但最接近24的一个最大最优解。计算的没一步不能出现负数,不能出现小数。如四个个数为分别为4 9 8 10,则有如下3种不同算法:<br />(8*(4-(10-9))) = 24<br />(8*(9-(10-4))) = 24<br />(8*((9+4)-10)) = 24<br />如四个数分别为 8 9 7 7,则没有正确解,则输出一个最优解<br
去csdn找吧
main()
{
xxxxx
}
printf("我也不知道这么做",xxxx.XXXX)

哈哈
#include "stdio.h"
#include "math.h"
#include "time.h"

void main()
{
void first();
void second();
int third();
time_t t;
int close=0;
char get;
clrscr();
srand((unsigned) time(&t));
for(;;)
{
clrscr();
printf("24 POINTS SYSTEM v2.2\n");
printf("MADE BY DANTE WANG\n");
printf("Jul.28th 2006\n\n");
printf("Please choose mode!\n\n");
printf("1. Game Mode\n");
printf("2. Count Mode\n");
printf("3. Quit\n\n");
get=getch();
switch(get)
{
case '1': first(); break;
case '2': second();break;
case '3': close=third(); break;
default: printf("Please input 1, 2 or 3!\n"); getch();
}
if(close)
break;
}
}

void first()
{
int jdgsgn(int a,int b,int c,int d);
int n[4],i;
char ch[100],ch1[100];
int check(char *p);
int exam2(char *p,int a,int b,int c,int d);
void sign(int a,int b,int c,int d);
double figure(char *p);
void draw(int *p);
for(;;)
{
for(i=0;i<4;i++)
{
n[i]=rand()%13+1;
}
draw(n);
if(!jdgsgn(n[0],n[1],n[2],n[3]))
{
printf("No answer!");
getch();
continue;
}
gets(ch);
if(!strcmp(strlwr(ch),"quit"))
break;
else
{
strcpy(ch1,ch);
if(!check(ch)&&!exam2(ch,n[0],n[1],n[2],n[3])&&fabs(figure(ch1)-24)<=0.000001)
{
printf("\nGood job!\n");
getch();
}
else
{
printf("\nWrong!\n\nAnswer: ");
sign(n[0],n[1],n[2],n[3]);
getch();
}
}
}
}

void second()
{
int n[4],i;
char c[4][10];
int exam(char *p);
void sign(int a,int b,int c,int d);
double recog(char *p);
clrscr();
printf("Input 0 to leave.\n\n");
for(;;)
{
for(i=0;i<4;i++)
{
scanf("%s&quo
{
printf("%-5d%-8s%-6s%-13s%-15s%-15s\n",per[i-1].score,per[i-1].name,per[i-1].age,per[i-1].num,per[i-1].adds,per[i-1].email);
if(i>1&&i%10==0)
{
printf("\t-----------------------------------\n");
printf("\t");
system("pause");
printf("\t-----------------------------------\n");
}
}
{
printf("%-5d%-8s%-6s%-13s%-15s%-15s\n",per[i-1].score,per[i-1].name,per[i-1].age,per[i-1].num,per[i-1].adds,per[i-1].email);
if(i>1&&i%10==0)
{
printf("\t-----------------------------------\n");
printf("\t");
system("pause");
printf("\t-----------------------------------\n");
}
}
去csdn找吧
main()
{
xxxxx
}
printf("我也不知道这么做",xxxx.XXXX)

哈哈
#include "stdio.h"
#include "math.h"
#include "time.h"

void main()
{
void first();
void second();
int third();
time_t t;
int close=0;
char get;
clrscr();
srand((unsigned) time(&t));
for(;;)
{
clrscr();
printf("24 POINTS SYSTEM v2.2\n");
printf("MADE BY DANTE WANG\n");
printf("Jul.28th 2006\n\n");
printf("Please choose mode!\n\n");
printf("1. Game Mode\n");
printf("2. Count Mode\n");
printf("3. Quit\n\n");
get=getch();
switch(get)
{
case '1': first(); break;
case '2': second();break;
case '3': close=third(); break;
default: printf("Please input 1, 2 or 3!\n"); getch();
}
if(close)
break;
}
}

void first()
{
int jdgsgn(int a,int b,int c,int d);
int n[4],i;
char ch[100],ch1[100];
int check(char *p);
int exam2(char *p,int a,int b,int c,int d);
void sign(int a,int b,int c,int d);
double figure(char *p);
void draw(int *p);
for(;;)
{
for(i=0;i<4;i++)
{
n[i]=rand()%13+1;
}
draw(n);
if(!jdgsgn(n[0],n[1],n[2],n[3]))
{
printf("No answer!");
getch();
continue;
}
gets(ch);
if(!strcmp(strlwr(ch),"quit"))
break;
else
{
strcpy(ch1,ch);
if(!check(ch)&&!exam2(ch,n[0],n[1],n[2],n[3])&&fabs(figure(ch1)-24)<=0.000001)
{
printf("\nGood job!\n");
getch();
}
else
{
printf("\nWrong!\n\nAnswer: ");
sign(n[0],n[1],n[2],n[3]);
getch();
}
}
}
}

void second()
{
int n[4],i;
char c[4][10];
int exam(char *p);
void sign(int a,int b,int c,int d);
double recog(char *p);
clrscr();
printf("Input 0 to leave.\n\n");
for(;;)
{
for(i=0;i<4;i++)
{
scanf("%s&quo
http://zhidao.baidu.com/question/282083324html