// sum 和test24 的函数你哪儿不懂追问吧
//限制在1-13的方法可以用下面的
int main(){
float sum(float,float,char);
void test24(float [],char []);
int i,j,k,l,q,r,s,t,n=0;
float a[4];
char f[4]={'+','-','*','/'};
float x[4];
char y[3];
int go=1;
while(go==1){
printf("Please input how many resualts every break prints?\n");
scanf("%d",&page);
printf("Please input the 4 num to 24:\n");
scanf("%f%f%f%f",&a[0],&a[1],&a[2],&a[3]);
scanf("%c",&temp);
/*新加的 begin*/
int input_flag=1;
for(int input_num=0;input_num<4;input_num++)
{
if(a[input_num]>13 || a[input_num]<=0){
input_flag=0;
continue;
}
}
/*end*/
if(input_flag)
{
printf("\n******Resualt:******\n");
/*get 4 num*/
total=0;
for(i=0;i<4;i++){
for(j=0;j<4;j++){
if(i==j) continue;
for(k=0;k<4;k++){
if(k==i||k==j) continue;
for(l=0;l<4;l++){
if(l==i||l==j||l==k) continue;
x[0]=a[i];
x[1]=a[j];
x[2]=a[k];
x[3]=a[l];
/*get +-*/
for(q=0;q<4;q++){
y[0]=f[q];
for(r=0;r<4;r++){
y[1]=f[r];
for(s=0;s<4;s++){
y[2]=f[s];
/*start*/
test24(x,y);
}
}
}
n++;
}
}
}
}
printf("total=%d\n",total);
printf("******end******\n");
printf("continue? 1:yes 2:no\n");
}else
{
printf("Please input the number between 1 and 13! ontinue? 1:yes 2:no\n");
}
scanf("%d",&go);
}
printf("Bye!\n");
return 0;
}
不知道