void print_metrics(){ int i=0; ofstream unset; string nullstr(""); mse one(NULL, NULL, -1, -1, unset, nullstr); cout<<"\t"<<++i<<": "<<one.get_metric_name()<<"\n"; rmse two(NULL, NULL, -1, -1, unset, nullstr); cout<<"\t"<<++i<<": "<<two.get_metric_name()<<"\n"; scc three(NULL, NULL, -1, -1, unset, nullstr); cout<<"\t"<<++i<<": "<<three.get_metric_name()<<"\n"; difmap four(NULL, NULL, -1, -1, unset, nullstr); cout<<"\t"<<++i<<": "<<four.get_metric_name()<<"\n"; difmap_wkey five(NULL, NULL, -1, -1, unset, nullstr); cout<<"\t"<<++i<<": "<<five.get_metric_name()<<"\n"; colmap six(NULL, NULL, -1, -1, unset, nullstr); cout<<"\t"<<++i<<": "<<six.get_metric_name()<<"\n"; scorco seven(NULL, NULL, -1, -1, unset, nullstr); cout<<"\t"<<++i<<": "<<seven.get_metric_name()<<"\n"; modef eight(NULL, NULL, -1, -1, unset, nullstr); cout<<"\t"<<++i<<": "<<eight.get_metric_name()<<"\n"; }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); connect(ui->clear,SIGNAL(released()), this,SLOT(clear())); connect(ui->add,SIGNAL(released()), this,SLOT(add())); connect(ui->sub,SIGNAL(released()),this,SLOT(substract())); connect(ui->mul,SIGNAL(released()),this,SLOT(multiply())); connect(ui->div,SIGNAL(released()),this,SLOT(divide())); connect(ui->push_but_0,SIGNAL(released()),this,SLOT(zero())); connect(ui->push_but_1,SIGNAL(released()),this,SLOT(one())); connect(ui->push_but_2,SIGNAL(released()),this,SLOT(two())); connect(ui->push_but_3,SIGNAL(released()),this,SLOT(tree())); connect(ui->push_but_4,SIGNAL(released()),this,SLOT(four())); connect(ui->push_but_5,SIGNAL(released()),this,SLOT(five())); connect(ui->push_but_6,SIGNAL(released()),this,SLOT(six())); connect(ui->push_but_7,SIGNAL(released()),this,SLOT(seven())); connect(ui->push_but_8,SIGNAL(released()),this,SLOT(eight())); connect(ui->push_but_9,SIGNAL(released()),this,SLOT(nine())); connect(ui->equal,SIGNAL(released()),this,SLOT(equal())); connect(ui->point,SIGNAL(released()),this,SLOT(point())); connect(ui->convertingto8,SIGNAL(released()),this,SLOT(converting8())); connect(ui->point,SIGNAL(released()),this,SLOT(converting10())); }
TEST (kdbrestModelsEntryTest, SetAndGetAndHasTags) { kdb::Key key (kdbrest::Config::instance ().getConfig ().get<std::string> ("kdb.path.configs") + std::string ("/test/key1"), KEY_END); kdbrest::model::Entry entry (key); const char * taglist[] = { "one", "two", "three", "four", "five" }; std::vector<std::string> tags (taglist, std::end (taglist)); entry.setTags (tags); std::vector<std::string> retTags = entry.getTags (); for (int i = 0; i < 5; i++) { ASSERT_TRUE (std::find (retTags.begin (), retTags.end (), taglist[i]) != retTags.end ()); } std::string one (taglist[0]); std::string three (taglist[2]); ASSERT_TRUE (entry.hasTag (one)); ASSERT_TRUE (entry.hasTag (three)); std::string seven ("seven"); std::string fou ("fou"); std::string five_uc ("FIVE"); ASSERT_FALSE (entry.hasTag (seven)); ASSERT_FALSE (entry.hasTag (fou)); ASSERT_FALSE (entry.hasTag (five_uc)); }
int main( int argc, char* argv[] ) { std::string const input = "namespace test {\n\ class c { int m; function f() ->void {} }\n\ function main() -> int\n\ {\n\ c tc;\n\ int one = two = three + four + five * not six * seven( 01, 02 )[03] + eight;\n\ { ::int abc = 2+2; }\n\ }\n\
void RunTests() { TreeNode root(3); TreeNode nine(9); TreeNode twenty(20); TreeNode fifteen(15); TreeNode seven(7); root.left = &nine; root.right = &twenty; twenty.left = &fifteen; twenty.right = &seven; Solution s; vector<vector<int>> output = s.levelOrder(&root); Solution s2; vector<vector<int>> output2 = s2.levelOrder(nullptr); }
void RunTests() { Solution s; TreeNode one(1); TreeNode two(2); TreeNode four(4); TreeNode four_2(4); TreeNode five(5); TreeNode five_2(5); TreeNode seven(7); TreeNode eight(8); TreeNode eleven(11); TreeNode thirteen(13); // Simple problems _ASSERT(s.pathSum(nullptr, 1).size() == 0); _ASSERT(s.pathSum(&one, 1).size() == 1); // Sample problem five.left = &four; five.right = &eight; four.left = &eleven; four.right = nullptr; eleven.left = &seven; eleven.right = &two; seven.left = nullptr; seven.right = nullptr; two.left = nullptr; two.right = nullptr; eight.left = &thirteen; eight.right = &four_2; thirteen.left = nullptr; thirteen.right = nullptr; four_2.left = &five_2; four_2.right = &one; five_2.left = nullptr; five_2.right = nullptr; one.left = nullptr; one.right = nullptr; _ASSERT(s.pathSum(&five, 22).size() == 2); }
void main() { FILE*file; int cases; int i,j,k; char number[110]; file=fopen("input.txt","r"); fscanf(file,"%d",&cases); for(i=0; i<cases; i++) { fscanf(file,"%s",number); k=strlen(number); for(j=0; j<k; j++) { number[j]-='0'; } printf("%d %d %d %d %d %d %d %d %d %d\n",two(number,k),three(number,k),four(number,k),five(number,k),six(number,k),seven(number,k),eight(number,k),nine(number,k),ten(number,k),eleven(number,k)); } }
void VariableTestFixture::testSimpleExpression() { Datum six(M_INTEGER, 6); ConstantVariable c1(six); Datum five(M_INTEGER, 5); ConstantVariable c2(five); // boolean expressions shared_ptr<ExpressionVariable> e; e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, &c2, M_IS_EQUAL)); CPPUNIT_ASSERT(!e->getValue().getBool()); e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c2, &c2, M_IS_EQUAL)); CPPUNIT_ASSERT(e->getValue().getBool()); e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, &c2, M_IS_NOT_EQUAL)); CPPUNIT_ASSERT(e->getValue().getBool()); e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, &c1, M_IS_NOT_EQUAL)); CPPUNIT_ASSERT(!e->getValue().getBool()); e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, &c2, M_IS_GREATER_THAN)); CPPUNIT_ASSERT(e->getValue().getBool()); e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c2, &c1, M_IS_GREATER_THAN)); CPPUNIT_ASSERT(!e->getValue().getBool()); e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, &c1, M_IS_GREATER_THAN)); CPPUNIT_ASSERT(!e->getValue().getBool()); e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, &c2, M_IS_GREATER_THAN_OR_EQUAL)); CPPUNIT_ASSERT(e->getValue().getBool()); e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c2, &c1, M_IS_GREATER_THAN_OR_EQUAL)); CPPUNIT_ASSERT(!e->getValue().getBool()); e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, &c1, M_IS_GREATER_THAN_OR_EQUAL)); CPPUNIT_ASSERT(e->getValue().getBool()); e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, &c2, M_IS_LESS_THAN)); CPPUNIT_ASSERT(!e->getValue().getBool()); e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c2, &c1, M_IS_LESS_THAN)); CPPUNIT_ASSERT(e->getValue().getBool()); e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, &c1, M_IS_LESS_THAN)); CPPUNIT_ASSERT(!e->getValue().getBool()); e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, &c2, M_IS_LESS_THAN_OR_EQUAL)); CPPUNIT_ASSERT(!e->getValue().getBool()); e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c2, &c1, M_IS_LESS_THAN_OR_EQUAL)); CPPUNIT_ASSERT(e->getValue().getBool()); e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, &c1, M_IS_LESS_THAN_OR_EQUAL)); CPPUNIT_ASSERT(e->getValue().getBool()); // arithmatic expressions e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, &c2, M_PLUS)); CPPUNIT_ASSERT(e->getValue().getInteger() == (long)(six + five)); e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, &c2, M_MINUS)); CPPUNIT_ASSERT(e->getValue().getInteger() == (long)(six - five)); e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, &c2, M_TIMES)); CPPUNIT_ASSERT(e->getValue().getFloat() == (float)(six * five)); e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, &c2, M_DIVIDE)); CPPUNIT_ASSERT(e->getValue().getFloat() == (double)(six / five)); e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, &c2, M_MOD)); CPPUNIT_ASSERT(e->getValue().getInteger() == (long)(six % five)); e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, &c2, M_INCREMENT)); CPPUNIT_ASSERT(e->getValue().getInteger() == (long)(six + Datum(M_FLOAT,1))); e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, &c2, M_DECREMENT)); CPPUNIT_ASSERT(e->getValue().getInteger() == (long)(six - Datum(M_FLOAT,1))); e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, NULL, M_INCREMENT)); CPPUNIT_ASSERT(e->getValue().getInteger() == (long)(six + Datum(M_FLOAT,1))); e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, NULL, M_DECREMENT)); CPPUNIT_ASSERT(e->getValue().getInteger() == (long)(six - Datum(M_FLOAT,1))); Datum seven(M_INTEGER, 0x7); ConstantVariable c3(seven); Datum eight(M_INTEGER, 0x8); ConstantVariable c4(eight); e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c3, &c4, M_AND)); CPPUNIT_ASSERT(e->getValue().getInteger() == (long)(seven && eight)); e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c3, &c4, M_OR)); CPPUNIT_ASSERT(e->getValue().getInteger() == (long)(seven || eight)); e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c3, &c4, M_NOT)); CPPUNIT_ASSERT(e->getValue().getInteger() == (long)(!seven)); e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c3, NULL, M_NOT)); CPPUNIT_ASSERT(e->getValue().getInteger() == (long)(!seven)); e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, &c2, M_UNARY_MINUS)); CPPUNIT_ASSERT(e->getValue().getInteger() == (long)(six)*-1); e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, NULL, M_UNARY_MINUS)); CPPUNIT_ASSERT(e->getValue().getInteger() == (long)(six)*-1); e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, &c2, M_UNARY_PLUS)); CPPUNIT_ASSERT(e->getValue().getInteger() == (long)(six)); e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, NULL, M_UNARY_PLUS)); CPPUNIT_ASSERT(e->getValue().getInteger() == (long)(six)); }
int main() { printf("== one() ==\n"); one(3, 4); one(10, 10); printf("== two() ==\n"); const char* a = "20"; two(a); const char* b = "100"; two(b); printf("== three() ==\n"); three(); printf("== four() ==\n"); four(0.5); four(1.5); printf("== five() ==\n"); const int num1 = 3; const int num2 = 3; five(&num1, &num2); const int num3 = 4; five(&num1, &num3); printf("== six() ==\n"); float *p_six; int i4 = 4, i432 = 432; p_six = six(&i4); printf("%d == %f\n", i4, *p_six); free(p_six); p_six = six(&i432); printf("%d == %f\n", i432, *p_six); free(p_six); printf("== seven() ==\n"); const char s = 'S'; seven(&s); const char t = '_'; seven(&t); printf("== eight() ==\n"); eight(); printf("== nine() ==\n"); nine(); printf("== ten() ==\n"); int i_ten = 100; ten(&i_ten); printf("%d == 0?\n", i_ten); printf("== eleven() ==\n"); eleven(); printf("== twelve() ==\n"); twelve(); printf("== thirteen() ==\n"); thirteen(10); printf("== fourteen() ==\n"); fourteen("red"); fourteen("orange"); fourteen("blue"); fourteen("green"); printf("== fifteen() ==\n"); fifteen(1); fifteen(2); fifteen(3); printf("== sixteen() ==\n"); char *str = sixteen(); printf("%s\n", str); free(str); printf("== seventeen() ==\n"); seventeen(35); seventeen(20); printf("== eighteen() ==\n"); eighteen(3); eighteen(5); printf("== clear_bits() ==\n"); long int result; result = clear_bits(0xFF, 0x55); printf("%ld\n", result); result = clear_bits(0x00, 0xF0); printf("%ld\n", result); result = clear_bits(0xAB, 0x00); printf("%ld\n", result); result = clear_bits(0xCA, 0xFE); printf("%ld\n", result); result = clear_bits(0x14, 0x00); printf("%ld\n", result); result = clear_bits(0xBB, 0xBB); printf("%ld\n", result); return 0; }
int main(){ printf("%d\n", seven()); }
int main(void) { i=EEPROM_read(Address); // de vazut adresele cum sunt puse! //timer_1(1000); // set value in ms DDRD = 0xf8; DDRB = 0xff; // set external interrupt on digital PIN 2 cli(); PORTD |= (1 << PORTD2); // turn On the Pull-up EICRA |= (1 << ISC00); // EICRA |= (1 << ISC01); // set INT0 to trigger on rising edge EIMSK |= (1 << INT0); // Turns on INT0 - external interrupt mask register sei(); clear(2); clear(1); while(1){ if(i<100 && i>=1){ nr_2=i%10; nr_1=i/10; if(nr_1>=1){ if(nr_1==0){ zero(1); } if(nr_1==1){ one(1); } if(nr_1==2){ two(1); } if(nr_1==3){ three(1); } if(nr_1==4){ four(1); } if(nr_1==5){ five(1); } if(nr_1==6){ six(1); } if(nr_1==7){ seven(1); } if(nr_1==8){ eight(1); } if(nr_1==9){ nine(1); } } if(nr_2==0){ zero(2); } if(nr_2==1){ one(2); } if(nr_2==2){ two(2); } if(nr_2==3){ three(2); } if(nr_2==4){ four(2); } if(nr_2==5){ five(2); } if(nr_2==6){ six(2); } if(nr_2==7){ seven(2); } if(nr_2==8){ eight(2); } if(nr_2==9){ nine(2); } } else{ i=0; clear(2); clear(1); } EEPROM_write(Address, i); } return 0; }
int main() { /* part1.c */ printf("== one() ==\n"); one(3, 4); one(10, 10); printf("== two() ==\n"); two(50); two(100); printf("== three() ==\n"); three(); printf("== four() ==\n"); four(0.5); four(1.5); printf("== five() ==\n"); five(3, 3); five(3, 4); /* part2.c */ printf("== six() ==\n"); float *p_six; int i4 = 4, i432 = 432; p_six = six(&i4); printf("%d == %f\n", i4, *p_six); free(p_six); p_six = six(&i432); printf("%d == %f\n", i432, *p_six); free(p_six); printf("== seven() ==\n"); seven(2, 12); seven(14, 20); printf("== eight() ==\n"); eight(); printf("== nine() ==\n"); nine(); printf("== ten() ==\n"); int i_ten = 100; ten(&i_ten); printf("%d == 0?\n", i_ten); /* part3.c */ printf("== eleven() ==\n"); eleven(); printf("== twelve() ==\n"); twelve(); printf("== thirteen() ==\n"); thirteen(); printf("== fourteen() ==\n"); fourteen("red"); fourteen("orange"); fourteen("blue"); fourteen("green"); printf("== fifteen() ==\n"); fifteen(1); fifteen(2); fifteen(3); /* part4.c */ printf("== sixteen() ==\n"); char *str = sixteen(); printf("%s\n", str); free(str); printf("== seventeen() ==\n"); seventeen(35); seventeen(20); printf("== eighteen() ==\n"); eighteen(3); eighteen(5); printf("== clear_bits() ==\n"); long int result; result = clear_bits(0xFF, 0x55); printf("%ld\n", result); result = clear_bits(0x00, 0xF0); printf("%ld\n", result); result = clear_bits(0xAB, 0x00); printf("%ld\n", result); result = clear_bits(0xCA, 0xFE); printf("%ld\n", result); result = clear_bits(0x14, 0x00); printf("%ld\n", result); result = clear_bits(0xBB, 0xBB); printf("%ld\n", result); return 0; }
Limbs::Limbs(Encoding &g) :genome(g) { //create Traits Trait spindly(1, -3, 3, "spindly"); Trait thin(1, -2, 1, "thin"); Trait thick(-2, 3, 0, "thick"); Trait round(3, -1, -1, "round"); Trait zero(0, 0, 3, "0"); Trait one(1, 1, 3, "1"); Trait two(3, 1, -3, "2"); Trait three(-1, 1, 3, "3"); Trait four(3, 1, -3, "4"); Trait five(-1, 1, 3, "5"); Trait six(2, 1, -3, "6"); Trait seven(-2, 2, 3, "7"); Trait eight(0, 3, 2, "8"); Trait nine(-3, 2, 3, "9"); Trait ten(-2, 3, 2, "10"); Trait eleven(-3, 2, 3, "11"); Trait twelve(-3, 3, 2, "12"); Trait thirteen(-3, 2, 3, "13"); Trait fourteen(-3, 3, 3, "14"); Trait fifteen(-3, 2, 3, "15"); //create all maps if (thicknessK.empty() ) { thicknessK["spindly"] = 0; thicknessK["thin"] = 1; thicknessK["thick"] = 2; thicknessK["round"] = 3; thicknessM[0] = spindly; thicknessM[1] = thin; thicknessM[2] = thick; thicknessM[3] = round; numM[0] = zero; numM[1] = one; numM[2] = two; numM[3] = three; numM[4] = four; numM[5] = five; numM[6] = six; numM[7] = seven; numM[8] = eight; numM[9] = nine; numM[10] = ten; numM[11] = eleven; numM[12] = twelve; numM[13] = thirteen; numM[14] = fourteen; numM[15] = fifteen; } //decode the number of limbs so that there can //only be a non-zero even number of them number = decodeNumber(); int numValue = std::stoi(number); if (numValue % 2 != 0) { encodeNumber(numValue + 1); number = decodeNumber(); } if (numValue == 0) { encodeNumber(2); number = decodeNumber(); } thickness = decodeThickness(); }