在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
1 //最终版 2 #include <iostream> 3 #include <cmath> 4 using namespace std; 5 double ans2(char* c) 6 { 7 double a,b; 8 double sum; 9 char t; 10 a=c[2]-48;b=c[4]-48; 11 t=c[3]; 12 // cout<<"a: "<<a<<"b: "<<b<<"t: "<<t<<endl; 13 if(t=='+') 14 {sum=a+b;} 15 if(t=='-') 16 {sum=a-b;} 17 if(t=='*') 18 {sum=a*b;} 19 if(t=='/') 20 {sum=a/b;} 21 //cout<<sum<<endl; 22 a=sum;b=c[7]-48; 23 t=c[6]; 24 // cout<<"a: "<<a<<"b: "<<b<<"t: "<<t<<endl; 25 if(t=='+') 26 {sum=a+b;} 27 if(t=='-') 28 {sum=a-b;} 29 if(t=='*') 30 {sum=a*b;} 31 if(t=='/') 32 {sum=a/b;} 33 a=sum;b=c[10]-48; 34 t=c[9]; 35 // cout<<"a: "<<a<<"b: "<<b<<"t: "<<t<<endl; 36 if(t=='+') 37 {sum=a+b;} 38 if(t=='-') 39 {sum=a-b;} 40 if(t=='*') 41 {sum=a*b;} 42 if(t=='/') 43 {sum=a/b;} 44 return sum; 45 } 46 double ans3(char* c) 47 { 48 char t; 49 double a,b; 50 double sum1=0,sum2=0,sum=0; 51 a=c[1]-48; b=c[3]-48; t=c[2]; 52 if(t=='+') 53 {sum1=a+b;} 54 if(t=='-') 55 {sum1=a-b;} 56 if(t=='*') 57 {sum1=a*b;} 58 if(t=='/') 59 {sum1=a/b;} 60 a=c[7]-48; b=c[9]-48; t=c[8]; 61 if(t=='+') 62 {sum2=a+b;} 63 if(t=='-') 64 {sum2=a-b;} 65 if(t=='*') 66 {sum2=a*b;} 67 if(t=='/') 68 {sum2=a/b;} 69 a=sum1; b=sum2; t=c[5]; 70 if(t=='+') 71 {sum=a+b;} 72 if(t=='-') 73 {sum=a-b;} 74 if(t=='*') 75 {sum=a*b;} 76 if(t=='/') 77 {sum=a/b;} 78 return sum; 79 } 80 double ans4(char* c) 81 { 82 char t; 83 double a,b; 84 double sum1=0,sum2=0,sum=0; 85 a=c[4]-48; b=c[6]-48; t=c[5]; 86 if(t=='+') 87 {sum1=a+b;} 88 if(t=='-') 89 {sum1=a-b;} 90 if(t=='*') 91 {sum1=a*b;} 92 if(t=='/') 93 {sum1=a/b;} 94 a=c[1]-48; b=sum1; t=c[2]; 95 if(t=='+') 96 {sum2=a+b;} 97 if(t=='-') 98 {sum2=a-b;} 99 if(t=='*') 100 {sum2=a*b;} 101 if(t=='/') 102 {sum2=a/b;} 103 a=sum2; b=c[10]-48; t=c[9]; 104 if(t=='+') 105 {sum=a+b;} 106 if(t=='-') 107 {sum=a-b;} 108 if(t=='*') 109 {sum=a*b;} 110 if(t=='/') 111 {sum=a/b;} 112 return sum; 113 } 114 double ans5(char* c) 115 { 116 char t; 117 double a,b; 118 double sum1=0,sum2=0,sum=0; 119 a=c[4]-48; b=c[6]-48; t=c[5]; 120 if(t=='+') 121 {sum1=a+b;} 122 if(t=='-') 123 {sum1=a-b;} 124 if(t=='*') 125 {sum1=a*b;} 126 if(t=='/') 127 {sum1=a/b;} 128 a=sum1; b=c[9]-48; t=c[8]; 129 if(t=='+') 130 {sum2=a+b;} 131 if(t=='-') 132 {sum2=a-b;} 133 if(t=='*') 134 {sum2=a*b;} 135 if(t=='/') 136 {sum2=a/b;} 137 a=c[0]-48; b=sum2; t=c[1]; 138 if(t=='+') 139 {sum=a+b;} 140 if(t=='-') 141 {sum=a-b;} 142 if(t=='*') 143 {sum=a*b;} 144 if(t=='/') 145 {sum=a/b;} 146 return sum; 147 } 148 double ans6(char* c) 149 { 150 char t; 151 double a,b; 152 double sum1=0,sum2=0,sum=0; 153 a=c[6]-48; b=c[8]-48; t=c[7]; 154 if(t=='+') 155 {sum1=a+b;} 156 if(t=='-') 157 {sum1=a-b;} 158 if(t=='*') 159 {sum1=a*b;} 160 if(t=='/') 161 {sum1=a/b;} 162 a=c[3]-48; b=sum1; t=c[4]; 163 if(t=='+') 164 {sum2=a+b;} 165 if(t=='-') 166 {sum2=a-b;} 167 if(t=='*') 168 {sum2=a*b;} 169 if(t=='/') 170 {sum2=a/b;} 171 a=c[0]-48; b=sum2; t=c[1]; 172 if(t=='+') 173 {sum=a+b;} 174 if(t=='-') 175 {sum=a-b;} 176 if(t=='*') 177 {sum=a*b;} 178 if(t=='/') 179 {sum=a/b;} 180 return sum; 181 } 182 void fkind(char* a,int n,int i,char* t,char *p) 183 { 184 static int tot=0; 185 if(i==n) 186 { 187 for(int j=0;j<n;j++) 188 { 189 // cout<<t[j]<<" "; 190 p[tot++]=t[j]; 191 } 192 // cout<<endl; 193 // cout<<endl<<tot++<<endl; 194 } 195 else if(i<n) 196 { 197 for(int j=0;j<4;j++) 198 { 199 t[i]=a[j]; 200 fkind(a,n,i+1,t,p); 201 } 202 } 203 } 204 void nkind(int* a,int n,int i,int* t,int *p) 205 { 206 static int tot=0; 207 if(i==n) 208 { 209 for(int j=0;j<n;j++) 210 { 211 // cout<<t[j]<<" "; 212 p[tot++]=t[j]; 213 } 214 // cout<<endl; 215 // cout<<endl<<tot++<<endl; 216 } 217 else if(i<n) 218 { 219 for(int j=0;j<4;j++) 220 { 221 if(a[j]!=-1) 222 { 223 t[i]=a[j]; 224 int s=a[j]; 225 a[j]=-1; 226 nkind(a,n,i+1,t,p); 227 a[j]=s; 228 } 229 } 230 } 231 } 232 void equation(int* a,char* b,char* c) 233 { 234 c[0]=c[1]='('; 235 c[5]=c[8]=')'; 236 c[2]=a[0]+48; 237 c[4]=a[1]+48; 238 c[7]=a[2]+48; 239 c[10]=a[3]+48; 240 c[3]=b[0]; 241 c[6]=b[1]; 242 c[9]=b[2]; 243 c[11]='\0'; 244 } 245 void equation3(int* a,char* b,char* c) 246 { 247 c[0]=c[6]='('; 248 c[4]=c[10]=')'; 249 c[1]=a[0]+48; 250 c[3]=a[1]+48; 251 c[7]=a[2]+48; 252 c[9]=a[3]+48; 253 c[2]=b[0]; 254 c[5]=b[1]; 255 c[8]=b[2]; 256 c[11]='\0'; 257 } 258 void equation4(int* a,char* b,char* c) 259 { 260 c[0]=c[3]='('; 261 c[8]=c[7]=')'; 262 c[1]=a[0]+48; 263 c[4]=a[1]+48; 264 c[6]=a[2]+48; 265 c[10]=a[3]+48; 266 c[2]=b[0]; 267 c[5]=b[1]; 268 c[9]=b[2]; 269 c[11]='\0'; 270 } 271 void equation5(int* a,char* b,char* c) 272 { 273 c[2]=c[3]='('; 274 c[10]=c[7]=')'; 275 c[0]=a[0]+48; 276 c[4]=a[1]+48; 277 c[6]=a[2]+48; 278 c[9]=a[3]+48; 279 c[1]=b[0]; 280 c[5]=b[1]; 281 c[8]=b[2]; 282 c[11]='\0'; 283 } 284 void equation6(int* a,char* b,char* c) 285 { 286 c[2]=c[5]='('; 287 c[10]=c[9]=')'; 288 c[0]=a[0]+48; 289 c[3]=a[1]+48; 290 c[6]=a[2]+48; 291 c[8]=a[3]+48; 292 c[1]=b[0]; 293 c[4]=b[1]; 294 c[7]=b[2]; 295 c[11]='\0'; 296 } 297 void actoa2(int* a,char (*p)[5],int *sig) 298 { 299 int i=0; 300 for(i=0;i<4;i++) 301 { 302 if(sig[i]==1) 303 { 304 if(*(p+i)[0]=='1') a[i]=1; 305 if(*(p+i)[0]=='2') a[i]=2; 306 if(*(p+i)[0]=='3') a[i]=3; 307 if(*(p+i)[0]=='4') a[i]=4; 308 if(*(p+i)[0]=='5') a[i]=5; 全部评论
专题导读
热门推荐
阅读排行榜
|
请发表评论