00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <FL/fl_ask.H>
00022
00023 using namespace std;
00024
00025
00026
00027
00028 void formula::solveFormula()
00029 {
00030 N = 12;
00031 a = logic_a->value();
00032 b = logic_b->value();
00033 c = logic_c->value();
00034
00035 w = in_w->value();
00036 x = in_x->value();
00037 y = in_y->value();
00038 z = in_z->value();
00039
00040 if ((b == 2) or (b == 4) or (b == 6) or (b == 8) or (b == 10) or (b == 12))
00041 {
00042 if ((c == 2) or (c == 4) or (c == 6) or (c == 8) or (c == 10) or (c == 12))
00043 {
00044 if (c!=b)
00045 {
00046 if ((c <= N/2) and ( c < b))
00047 {
00048 show_formula->value("case: 1");
00049 caso = 1;
00050 u = z;
00051 v = y;
00052 }
00053 else
00054 if((c <= N/2) and ( c > b))
00055 {
00056 show_formula->value("case: 2");
00057 caso = 2;
00058 u = y;
00059 v = z;
00060 }
00061 else
00062 if((c >= N/2+1) and ( c < b))
00063 {
00064 show_formula->value("case: 3");
00065 caso = 3;
00066 u = z;
00067 v = y;
00068 }
00069 else
00070 if((c >= N/2+1) and ( c > b))
00071 {
00072 show_formula->value("case: 4");
00073 caso = 4;
00074 u = y;
00075 v = z;
00076 }
00077 }
00078 }
00079 else
00080 if ((c == 1) or (c == 3) or (c == 5) or (c == 7) or (c == 9) or (c == 11))
00081 {
00082 if (c!=b)
00083 {
00084 if ((c <= N/2) and ( c < b))
00085 {
00086 show_formula->value("case: 5");
00087 caso = 5;
00088 u = z;
00089 v = x;
00090 }
00091 else
00092 if((c <= N/2) and ( c > b))
00093 {
00094 show_formula->value("case: 6");
00095 caso = 6;
00096 u = x;
00097 v = z;
00098 }
00099 else
00100 if((c >= N/2+1) and ( c < b))
00101 {
00102 show_formula->value("case: 7");
00103 caso = 7;
00104 u = z;
00105 v = x;
00106 }
00107 else
00108 if((c >= N/2+1) and ( c > b))
00109 {
00110 show_formula->value("case: 8");
00111 caso = 8;
00112 u = x;
00113 v = z;
00114 }
00115 }
00116 }
00117 }
00118
00119 if ((b == 1) or (b == 3) or (b == 5) or (b == 7) or (b == 9) or (b == 11))
00120 {
00121 if ((c == 2) or (c == 4) or (c == 6) or (c == 8) or (c == 10) or (c == 12))
00122 {
00123 if (c!=b)
00124 {
00125 if ((c <= N/2) and ( c < b))
00126 {
00127 show_formula->value("case: 9");
00128 caso = 9;
00129 u = y;
00130 v = x;
00131 }
00132 else
00133 if((c <= N/2) and ( c > b))
00134 {
00135 show_formula->value("case: 10");
00136 caso = 10;
00137 u = x;
00138 v = y;
00139 }
00140 else
00141 if((c >= N/2+1) and ( c < b))
00142 {
00143 show_formula->value("case: 11");
00144 caso = 11;
00145 u = y;
00146 v = x;
00147 }
00148 else
00149 if((c >= N/2+1) and ( c > b))
00150 {
00151 show_formula->value("case: 12");
00152 caso = 12;
00153 u = x;
00154 v = y;
00155 }
00156 }
00157 }
00158 else
00159 if ((c == 1) or (c == 3) or (c == 5) or (c == 7) or (c == 9) or (c == 11))
00160 {
00161 if (c!=b)
00162 {
00163 if ((c <= N/2) and ( c < b))
00164 {
00165 show_formula->value("case: 13");
00166 caso = 13;
00167 u = x;
00168 v = w;
00169 }
00170 else
00171 if((c <= N/2) and ( c > b))
00172 {
00173 show_formula->value("case: 14");
00174 caso = 14;
00175 u = w;
00176 v = x;
00177 }
00178 else
00179 if((c >= N/2+1) and ( c < b))
00180 {
00181 show_formula->value("case: 15");
00182 caso = 15;
00183 u = x;
00184 v = w;
00185 }
00186 else
00187 if((c >= N/2+1) and ( c > b))
00188 {
00189 show_formula->value("case: 16");
00190 caso = 16;
00191 u = w;
00192 v = x;
00193 }
00194 }
00195 }
00196 }
00197 }
00198
00199 void solveFormula()
00200 {
00201 formula obj;
00202
00203 obj.solveFormula();
00204 }
00205
00206 void solveFormula_cb(Fl_Widget *, void *)
00207 {
00208 solveFormula();
00209 }
00210
00211
00212
00213
00214
00215
00216 void formula::init_r()
00217 {
00218 srand(time(0));
00219 _x=((int)num)/RAND_MAX;
00220 }
00221
00222 int formula::gen_triple()
00223 {
00224 init_r();
00225 num = rand();
00226 j = num%12;
00227 num = rand();
00228 k = num%12;
00229 num = rand();
00230 l = num%12;
00231 }
00232
00233 void formula::out_formula()
00234 {
00235 gen_triple();
00236 logic_a->value(j);
00237 logic_b->value(k);
00238 logic_c->value(l);
00239 solveFormula();
00240 }
00241
00242 int formula::trp_seq()
00243 {
00244 init_r();
00245 int i = 0;
00246 for (i=0;i<logic_c->value();i++)
00247 {
00248 num = rand();
00249 j = num%11;
00250
00251 num = rand();
00252 k = num%11;
00253
00254 num = rand();
00255 l = num%11;
00256 }
00257
00258 return 0;
00259
00260 }
00261
00262 int formula::trp_seq_tcrom()
00263 {
00264 int i = 0;
00265 int perc;
00266 init_r();
00267 window->redraw();
00268 perc = max_pch->value() - min_pch->value() - 1;
00269
00270 num = rand();
00271 j_p1 = num%perc;
00272
00273 num = rand();
00274 j_p2 = num%perc;
00275
00276 num = rand();
00277 j_p3 = num%perc;
00278
00279 num = rand();
00280 j_p4 = num%perc;
00281
00282 num = rand();
00283 j_p5 = num%perc;
00284
00285 num = rand();
00286 j_p6 = num%perc;
00287
00288 num = rand();
00289 j_p7 = num%perc;
00290
00291 num = rand();
00292 j_p8 = num%perc;
00293
00294 num = rand();
00295 j_p9 = num%perc;
00296
00297 num = rand();
00298 j_p10 = num%perc;
00299
00300 num = rand();
00301 j_p11 = num%perc;
00302
00303 num = rand();
00304 j_p12 = num%perc;
00305
00306 num = rand();
00307 k_p = num%perc;
00308
00309 num = rand();
00310 l_p = num%perc;
00311
00312 return 0;
00313 }
00314
00315
00316 int formula::trp_seq_tinstr()
00317 {
00318 init_r();
00319 int i = 0;
00320 window->redraw();
00321 int perc = max_instr->value() - min_instr->value() - 1;
00322
00323 num = rand();
00324 j_i1 = num%perc;
00325
00326 num = rand();
00327 j_i2 = num%perc;
00328
00329 num = rand();
00330 j_i3 = num%perc;
00331
00332 num = rand();
00333 j_i4 = num%perc;
00334
00335 num = rand();
00336 j_i5 = num%perc;
00337
00338 num = rand();
00339 j_i6 = num%perc;
00340
00341 num = rand();
00342 j_i7 = num%perc;
00343
00344 num = rand();
00345 j_i8 = num%perc;
00346
00347 num = rand();
00348 j_i9 = num%perc;
00349
00350 num = rand();
00351 j_i10 = num%perc;
00352
00353 num = rand();
00354 j_i11 = num%perc;
00355
00356 num = rand();
00357 j_i12 = num%perc;
00358
00359 return 0;
00360 }
00361
00362 int formula::trp_seq_tdur()
00363 {
00364 init_r();
00365 int i = 0;
00366 int perc;
00367 window->redraw();
00368
00369 perc = max_dur->value() - min_dur->value() - 1;
00370
00371 num = rand();
00372 j_d1 = num%perc;
00373
00374 num = rand();
00375 j_d2 = num%perc;
00376
00377 num = rand();
00378 j_d3 = num%perc;
00379
00380 num = rand();
00381 j_d4 = num%perc;
00382
00383 num = rand();
00384 j_d5 = num%perc;
00385
00386 num = rand();
00387 j_d6 = num%perc;
00388
00389 num = rand();
00390 j_d7 = num%perc;
00391
00392 num = rand();
00393 j_d8 = num%perc;
00394
00395 num = rand();
00396 j_d9 = num%perc;
00397
00398 num = rand();
00399 j_d10 = num%perc;
00400
00401 num = rand();
00402 j_d11 = num%perc;
00403
00404 num = rand();
00405 j_d12 = num%perc;
00406
00407 return 0;
00408 }
00409
00410 int formula::trp_seq_tdb()
00411 {
00412 init_r();
00413 int i = 0;
00414 int perc = max_db->value() - min_db->value() - 1;
00415
00416 num = rand();
00417 j_db1 = num%perc;
00418
00419 num = rand();
00420 j_db2 = num%perc;
00421
00422 num = rand();
00423 j_db3 = num%perc;
00424
00425 num = rand();
00426 j_db4 = num%perc;
00427
00428 num = rand();
00429 j_db5 = num%perc;
00430
00431 num = rand();
00432 j_db6 = num%perc;
00433
00434 num = rand();
00435 j_db7 = num%perc;
00436
00437 num = rand();
00438 j_db8 = num%perc;
00439
00440 num = rand();
00441 j_db9 = num%perc;
00442
00443 num = rand();
00444 j_db10 = num%perc;
00445
00446 num = rand();
00447 j_db11 = num%perc;
00448
00449 num = rand();
00450 j_db12 = num%perc;
00451
00452 return 0;
00453 }
00454
00455 int formula::trp_seq_tact()
00456 {
00457 init_r();
00458 int i = 0;
00459 int perc = (int)max_act->value() - (int)min_act->value() - 1;
00460
00461 num = rand();
00462 j_act1 = num%perc;
00463
00464 num = rand();
00465 j_act2 = num%perc;
00466
00467 num = rand();
00468 j_act3 = num%perc;
00469
00470 num = rand();
00471 j_act4 = num%perc;
00472
00473 num = rand();
00474 j_act5 = num%perc;
00475
00476 num = rand();
00477 j_act6 = num%perc;
00478
00479 num = rand();
00480 j_act7 = num%perc;
00481
00482 num = rand();
00483 j_act8 = num%perc;
00484
00485 num = rand();
00486 j_act9 = num%perc;
00487
00488 num = rand();
00489 j_act10 = num%perc;
00490
00491 num = rand();
00492 j_act11 = num%perc;
00493
00494 num = rand();
00495 j_act12 = num%perc;
00496
00497 return 0;
00498 }
00499
00500
00501
00502
00503
00504
00505