就是这个程序,,,,一拜帅哥.....二拜大侠......三拜帅哥+大侠,,,,,,,,
#include<iostream.h>
float a[4];
class suan
{
public:
void ab();
float abc(float m,float n,int op);
};
void main()
{
int i;
cout<<"please enter the 4 number.\n"
<<"The number should 0<?<14: \n";
for(i=0;i<4;i++)
{
cout<<i+1<<':'<<'\n';
cin >>a[i];
if(a[i]<0||a[i]>13){
cout<<"Sorry,the number is too big.\n"
<<"Please enter another number(0<?<14): \n";
cin <<a[i];
};
};
suan suan_shi;
suan_shi.ab()
};
void ab()
{
int i,j,k,u,v,w,x,y,z;
float b[6];
float c[3];
char s[5]= "1,+,-,*,/";
for(i=0;i<6;i++){
for(j=0;j<6;j++){
for(k=0;k<6;k++){
for(u=0;u<6;u++){
for(v=0;v<6;v++){
for(w=0;w<6;w++){
for(x=0;x<6;x++){
for(y=0;y<6;y++){
for(z=0;z<6;z++){
b[0]=abc(a[1],a[2],z);
b[1]=abc(a[1],a[3],y);
b[2]=abc(a[1],a[4],x);
b[3]=abc(a[2],a[3],w);
b[4]=abc(a[2],a[4],v);
b[5]=abc(a[3],a[4],u);
c[0]=abc(b[0],b[5],k);
c[1]=abc(b[1],b[4],j);
c[2]=abc(b[2],b[3],i);
if c[1]==24{
cout<<a[1]<<s[z]<<a[2]<<'='<<b[0]<<'\n'
<<a[3]<<s[u]<<a[4]<<'='<<b[5]<<'\n'
<<b[0]<<s[k]<<b[5]<<'='<<c[1]<<"\n\n\n";
};
if c[2]==24{
cout<<a[1]<<s[y]<<a[3]<<'='<<b[1]<<'\n'
<<a[2]<<s[v]<<a[4]<<'='<<b[4]<<'\n'
<<b[1]<<s[j]<<b[2]<<'='<<c[2]<<"\n\n\n";
};
if c[2]==24{
cout<<a[1]<<s[x]<<a[4]<<'='<<b[2]<<'\n'
<<a[2]<<s[w]<<a[3]<<'='<<b[3]<<'\n'
<<b[2]<<s[i]<<b[3]<<'='<<c[3]<<"\n\n\n";
};
};
};
};
};
};
};
};
};
};
};
float abc(float m,float n,int op)
{
float temp;
switch(op){
case 0:
temp=m+n;
break;
case 1:
temp=m-n;
break;
case 2:
temp=m*n;
break;
case 3:
temp=m/n;
break;
case 4:
temp=n/m;
break;
case 5:
temp=n-m;
break;
}
return temp;
};