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";

}
Example #2
0
main(){
if(!DEBUG){freopen("prime3.in","r",stdin);
freopen("prime3.out","w",stdout);}
int i,j,k;
scanf("%d %d",&sum,&lu);
for(z=s=p=0,i=3;i<10000;i++,i++){
    if(notp[i])continue;
    for(j=i*3;j<100000;j+=i*2)notp[j]=1;
}
for(i=10001;i<100000;i++,i++){
    if(notp[i])continue;
    for(j=i;j<100000;j+=i*2)notp[j]=1;
    d00=i/10000;d01=(i/1000)%10;d02=(i/100)%10;d03=(i/10)%10;d04=i%10;
    j=d00+d01+d02+d03+d04;
    if(sum==j){
        prime[p++]=i;
        if(d00==lu)primel[s++]=i;
        if(d01 && d02 && d03){
            if(d00==lu)primez[z++]=i;
        }
        notp[i]=0;
    }
}
Solve This Problem;
if(!aaa)puts("NONE");
else{
    qsort(ans,aaa,sizeof(ans[0]),cmp);
    six();
}
if(DEBUG)scanf(" ");
}
Example #3
0
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()));
}
Example #4
0
static void tst8() {
    params_ref      ps;
    reslimit        rlim;
    nlsat::solver s(rlim, ps);
    anum_manager & am     = s.am();
    nlsat::pmanager & pm  = s.pm();
    nlsat::assignment as(am);
    nlsat::explain& ex    = s.get_explain();
    nlsat::var x0, x1, x2, a, b, c, d;
    a  = s.mk_var(false);
    b  = s.mk_var(false);
    c  = s.mk_var(false);
    d  = s.mk_var(false);
    x0 = s.mk_var(false);
    x1 = s.mk_var(false);
    x2 = s.mk_var(false);

    polynomial_ref p1(pm), p2(pm), p3(pm), p4(pm), p5(pm);
    polynomial_ref _x0(pm), _x1(pm), _x2(pm);
    polynomial_ref _a(pm), _b(pm), _c(pm), _d(pm);
    _x0 = pm.mk_polynomial(x0);
    _x1 = pm.mk_polynomial(x1);
    _x2 = pm.mk_polynomial(x2);
    _a  = pm.mk_polynomial(a);
    _b  = pm.mk_polynomial(b);
    _c  = pm.mk_polynomial(c);
    _d  = pm.mk_polynomial(d);

    scoped_anum zero(am), one(am), two(am), six(am);
    am.set(zero, 0);
    am.set(one,  1);
    am.set(two,  2);
    am.set(six,  6);
    as.set(0, two); // a
    as.set(1, one); // b
    as.set(2, six); // c
    as.set(3, zero); // d
    as.set(4, zero); // x0
    as.set(5, zero); // x1
    as.set(6, two); // x2
    s.set_rvalues(as);

    nlsat::scoped_literal_vector lits(s);
    lits.push_back(mk_eq(s, (_a*_x2*_x2) - (_b*_x2) - _c));
    project(s, ex, x2, 1, lits.c_ptr());
}
Example #5
0
bool TestDiffieHellman(void){
    sel::LargeInt p(0), g(0), A(0), B(0), a(0), b(0), s1(0), s2(0), one(1), two(2), six(6), p1(0), p2(0);

    //p.BitGenerator(1024);
    p.Generate(4); //128 Bits
    p = p*six;
    p1 = p - one;
    p2 = p + one;

    //while((!p1.MillerRabinPrimality(6)) && (!p2.MillerRabinPrimality(6))){
    while((!p1.FermatPrimality()) && (!p2.FermatPrimality())){
        //p.BitGenerator(1024);
        p1 += six;
        //p1.Generate(8);
        p2 += six;
        //p2.Generate(8);
        std::cout << "ONE TURN" << std::endl;
    }

    g.BitGenerator(64);

    a.BitGenerator(384);

	std::cout << "FOUND !" << std::endl;

    b.BitGenerator(384);
    A = g;
    A.Modular_Exp(a, p);
    B = g;
    B.Modular_Exp(b, p);
    s1 = B;
    s1.Modular_Exp(a, p);
    s2 = A;
    s2.Modular_Exp(b, p);

    if(s1 == s2){
        return true;
    }
    else{
        return false;
    }
}
Example #6
0
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));
    }
}
Example #7
0
	GPL_UNS1,		/* GF_SKIP1 */
	GPL_UNS2,		/* GF_SKIP2 */
	GPL_UNS3,		/* GF_SKIP3 */
	one_sixty_five(GPL_NONE),/* GF_NEW_ROW_0 through GF_NEW_ROW_164 */
	GPL_UNS1,		/* GF_XXX1 */
	GPL_UNS2,		/* GF_XXX2 */
	GPL_UNS3,		/* GF_XXX3 */
	GPL_SGN4,		/* GF_XXX4 */
	GPL_SGN4,		/* GF_YYY */
	GPL_NONE,		/* GF_NOP */
	GPL_NONE,		/* GF_CHAR_LOC */
	GPL_NONE,		/* GF_CHAR_LOC0 */
	GPL_NONE,		/* GF_PRE */
	GPL_NONE,		/* GF_POST */
	GPL_NONE,		/* GF_POSTPOST */
	six(GPL_NONE)		/* 250 through 255 */
};

/*
 * Types of the various opcodes.
 */
char gf_gt[256] = {
	sixty_four(GT_PAINT0),	/* GF_PAINT_0 through GF_PAINT_63 */
	three(GT_PAINT),	/* GF_PAINT1 through GF_PAINT3 */
	GT_BOC,			/* GF_BOC */
	GT_BOC1,		/* GF_BOC1 */
	GT_EOC,			/* GF_EOC */
	GT_SKIP0,		/* GF_SKIP0 */
	three(GT_SKIP),		/* GF_SKIP1 through GF_SKIP3 */
	one_sixty_five(GT_NEW_ROW),/* GF_NEW_ROW_0 throgh GF_NEW_ROW_164 */
	four(GT_XXX),		/* GF_XXX1 through GF_XXX4 */
Example #8
0
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));
}
Example #9
0
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;
}
Example #10
0
    SEQ_S,			/* DVI_W1 through DVI_W4 */
    DPL_NONE,		/* DVI_X0 */
    SEQ_S,			/* DVI_X1 through DVI_X4 */
    SEQ_S,			/* DVI_DOWN1 through DVI_DOWN4 */
    DPL_NONE,		/* DVI_Y0 */
    SEQ_S,			/* DVI_Y1 through DVI_Y4 */
    DPL_NONE,		/* DVI_Z0 */
    SEQ_S,			/* DVI_Z1 through DVI_Z4 */
    sixty_four(DPL_NONE),	/* DVI_FNTNUM0 through DVI_FNTNUM63 */
    SEQ_U,			/* DVI_FNT1 through DVI_FNT4 */
    SEQ_U,			/* DVI_XXX1 through DVI_XXX4 */
    SEQ_U,			/* DVI_FNTDEF1 through DVI_FNTDEF4 */
    DPL_NONE,		/* DVI_PRE */
    DPL_NONE,		/* DVI_POST */
    DPL_NONE,		/* DVI_POSTPOST */
    six(DPL_NONE)		/* 250 through 255 */
};

char dvi_dt[256] = {
    one_twenty_eight(DT_CHAR),
    /* characters 0 through 127 */
    four(DT_SET),		/* DVI_SET1 through DVI_SET4 */
    DT_SETRULE,		/* DVI_SETRULE */
    four(DT_PUT),		/* DVI_PUT1 through DVI_PUT4 */
    DT_PUTRULE,		/* DVI_PUTRULE */
    DT_NOP,			/* DVI_NOP */
    DT_BOP,			/* DVI_BOP */
    DT_EOP,			/* DVI_EOP */
    DT_PUSH,		/* DVI_PUSH */
    DT_POP,			/* DVI_POP */
    four(DT_RIGHT),		/* DVI_RIGHT1 through DVI_RIGHT4 */
Example #11
0
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;     
}
Example #12
0
int main()
{
	Node<std::string> six("6");
	Node<std::string> five("5");
	Node<std::string> four("4");
	Node<std::string> three("3");
	Node<std::string> two("2");
	Node<std::string> one("1");
	Node<std::string> zero("0");

	DAG<std::string> myGraph;

	myGraph.beginTransaction();

	myGraph.addEdge(four, one);
	myGraph.addEdge(two, three);
	myGraph.addEdge(three, one);
	myGraph.addEdge(five, two);
	myGraph.addEdge(five, zero);
	myGraph.addEdge(four, zero);

	myGraph.endTransaction();

	myGraph.report();

	Node<std::string> next;
	if (myGraph.next(next))
	{
		std::cout << "Next: " << next.value << std::endl;
		myGraph.remove(next);
	}
	if (myGraph.next(next))
	{
		std::cout << "Next: " << next.value << std::endl;
		myGraph.remove(next);
	}

	myGraph.addNode(six);

	if (myGraph.next(next))
	{
		std::cout << "Next: " << next.value << std::endl;
		myGraph.remove(next);
	}
	if (myGraph.next(next))
	{
		std::cout << "Next: " << next.value << std::endl;
		myGraph.remove(next);
	}
	if (myGraph.next(next))
	{
		std::cout << "Next: " << next.value << std::endl;
		myGraph.remove(next);
	}
	if (myGraph.next(next))
	{
		std::cout << "Next: " << next.value << std::endl;
		myGraph.remove(next);
	}
	if (myGraph.next(next))
	{
		std::cout << "Next: " << next.value << std::endl;
		myGraph.remove(next);
	}

	return 0;
}
Example #13
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;
}
Example #14
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();


}