ç¨JAVAå¦ä½ç®åº24ç¹?
ç¹çæºä»£ç ,å 该å¯ä»¥è®¡ç®åº4åè¿ç® public class TestPoint{ public static void main(String[] args){ int index = 0 ; int temp = 0 ; int totalSUC = 0 ; int numb[] = new int[4];//the first four numbers double num[][] = new double[][3];//three numbers after calculating double total[] = new double[6];//the number after three steps of calculating double p[][] = new double[6][8]; double q[][] = new double[3][7]; //System.out.println(%); //System.out.println(/); System.out.println("\"a--b\"means\"b-a\""); System.out.println("\"a//b\"means\"b/a\"\n"); /* for(int h = 0; h <= 9; h ++)//Get the first four numbers for calculating and store into the array numb[4]; for(int i = 0; i <= 9; i ++) for(int j = 0; j <= 9; j ++) for(int k = 0; k <= 9; k ++){ numb[0] = h ; numb[1] = i ; numb[2] = j ; numb[3] = k ; }*/ for(int i = 0 ; i < 4 ; i ++){ numb = Integer.parseInt(args); } for(int i = 0; i < 3; i ++)//Get two of the four to calculate and then store the new number into the array p; for(int j = i + 1; j < 4 ; j ++,temp ++){ p[temp][0] = numb + numb[j]; p[temp][1] = numb - numb[j]; p[temp][2] = numb[j] - numb; p[temp][3] = numb * numb[j]; if(numb[j] != 0) p[temp][4] = numb / (double)numb[j]; else p[temp][4] = ; if(numb != 0) p[temp][5] = numb[j] / (double)numb; else p[temp][5] = ;
ç¹è®¡ç®å¨
ä½ å¥½
ä¸é¢çå°ç¨åºæä¸äºç¬¨ï¼è¯æ³å¾ç®åï¼
å®æ æ³å辨ä¸äºéå¤çæ åµ
ä½ç»æè¿æ¯åºæ¬æ£ç¡®ç
#include<iostream>
using namespace std;
int main(){
int i1,i2,i3,i4,v,n1,n2;
int num=0;
int a,b;
double t1,t2,t3,t4,choice[4],s1[4],s2[4][4],s3[2],t;
for(;;){
cout<<"########################## äºååç¹ ###################################\nåæ æ示ï¼A=1,J=,Q=,K=\n";
cout<<"请ç»åºä½ æ½å°ç第ä¸çï¼";
cin>>choice[0];
cout<<"请ç»åºä½ æ½å°ç第äºçï¼";
cin>>choice[1];
cout<<"请ç»åºä½ æ½å°ç第ä¸çï¼";
cin>>choice[2];
cout<<"请ç»åºä½ æ½å°ç第åçï¼";
cin>>choice[3];
cout<<"########################## THINKING ###################################\n";
for(b=0;b<=2;b++)
for(a=3;a>=1+b;a--)if(choice[a]<choice[a-1]){
t=choice[a-1];
choice[a-1]=choice[a];
choice[a]=t;}
for(int j=0;j<4;j++)cout<<j+1<<". "<<choice[j]<<" ";
cout<<"\n";
for(i1=0;i1<4;i1++){
t1=choice[i1];
for(i2=0;i2<4;i2++){ if((i1-1)!=0 && t1==choice[i1-1])break;
if(i2!=i1){
t2=choice[i2];
s1[0]=t1+t2;
s1[1]=t1-t2;
s1[2]=t1*t2;
s1[3]=t1/t2;
for(i3=0;i3<4;i3++){
if(i3!=i1&&i3!=i2){
t3=choice[i3];
for(v=0;v<4;v++)
{ s2[v][0]=s1[v]+t3;
s2[v][1]=s1[v]-t3;
s2[v][2]=s1[v]*t3;
s2[v][3]=s1[v]/t3;}
for(i4=0;i4<4;i4++){
if(i4!=i1&&i4!=i2&&i4!=i3){
t4=choice[i4];
for(n1=0;n1<4;n1++)for(n2=0;n2<4;n2++)
if(s2[n1][n2]+t4==||s2[n1][n2]-t4==||s2[n1][n2]*t4==||s2[n1][n2]/t4==){
cout<<"æ¾å°ä¸ç§ç»åæ¹æ¡ï¼\n(("<<t1;
if(s1[n1]==t1+t2)cout<<" + ";
if(s1[n1]==t1-t2)cout<<" - ";
if(s1[n1]==t1*t2)cout<<" * ";
if(s1[n1]==t1/t2)cout<<" / ";
if(n2==0)cout<<t2<<") + "<<t3;
if(n2==1)cout<<t2<<") - "<<t3;
if(n2==2)cout<<t2<<") * "<<t3;
if(n2==3)cout<<t2<<") / "<<t3;
if(s2[n1][n2]+t4==)cout<<") + "<<t4<<" = \n";
if(s2[n1][n2]-t4==)cout<<") - "<<t4<<" = \n";
if(s2[n1][n2]*t4==)cout<<") * "<<t4<<" = \n";
if(s2[n1][n2]/t4==)cout<<") / "<<t4<<" = \n";
num++;
}
}}}
}}}}
for(i1=0;i1<4;i1++){
t1=choice[i1];
for(i2=0;i2<4;i2++){
if(i2!=i1){
t2=choice[i2];
s1[0]=t1*t2;
s1[1]=t1/t2;
for(i3=0;i3<4;i3++){
if(i3!=i1&&i3!=i2){
t3=choice[i3];
for(i4=0;i4<4;i4++){
if(i4!=i1&&i4!=i2&&i4!=i3){
t4=choice[i4];
s3[0]=t3*t4;
s3[1]=t3/t4;
for(n1=0;n1<2;n1++)for(n2=0;n2<2;n2++)
if(s1[n1]+s3[n2]==||s1[n1]-s3[n2]==){
cout<<"æ¾å°ä¸ç§ç»åæ¹æ¡ï¼\n("<<t1;
if(s1[n1]==t1*t2)cout<<" * ";
if(s1[n1]==t1/t2)cout<<" / ";
if(s1[n1]+s3[n2]==)cout<<t2<<") + ("<<t3;
if(s1[n1]-s3[n2]==)cout<<t2<<") - ("<<t3;
if(s3[n2]==t3*t4)cout<<" * "<<t4<<") = \n";
if(s3[n2]==t3/t4)cout<<" / "<<t4<<") = \n";
num++;
}
}}}
}}}}
cout<<"æ»å ±æ"<<num<<"ç§è§£æ³ã\n";
if(num==0)cout<<"è¿åå¼ çæ æ³ææç¹~~~\n";
num=0;
}
return 0;
}
2024-12-24 00:15
2024-12-24 00:04
2024-12-23 23:30
2024-12-23 23:20
2024-12-23 22:06