Ejemplo n.º 1
0
int generate(int x){
	time_t l;
	int p = 0, q = 0, i, j;
	srand((unsigned)time(&l));
	int k = rand() % 100;
	if(k % 2 == 1){
		answer1();
	}
	else
		answer2();
	switch(x){
		case 1:
			p = easy();
			break;
		case 2:
			p = medium();
			break;
		case 3:
			p = hard();
			break;
	}
	for(i = 1; i < 10; i++){
		for(j = 1; j < 10; j++){
			sudoko.b[i][j] = 0;
		}
	}
	while(q < p){
		sudoko.b[a[q]][b[q]] = sudoko.c[a[q]][b[q]];
		q++;
	}
	for(i = 1; i < 10; i++){
		for(j = 1; j < 10; j++){
			t[i][j] = sudoko.a[i][j] = 0;
		}
	}
	for(i = 1; i < 10; i++){
		for(j = 1; j < 10; j++){
			t[i][j] = sudoko.a[i][j] = sudoko.b[i][j];
		}
	}
	return 0;
}
Ejemplo n.º 2
0
int main()
{
   Q_ASSERT(*answer2() == 42);
   return 0;
}
Ejemplo n.º 3
0
void
CohesiveSurface3d :: computeBmatrixAt(GaussPoint *gp, FloatMatrix &answer, int li, int ui)
// Returns the strain-displacement matrix of the receiver.
{
    double x01, y01, z01, x02, y02, z02;
    FloatMatrix Bloc(3, 12);

    Node *nodeA, *nodeB;
    nodeA   = this->giveNode(1);
    nodeB   = this->giveNode(2);

    switch ( numberOfDofMans ) {
    case 2:
        // Coordinate differences
        x01 = nodeA->giveCoordinate(1) - center.at(1);
        y01 = nodeA->giveCoordinate(2) - center.at(2);
        z01 = nodeA->giveCoordinate(3) - center.at(3);
        x02 = nodeB->giveCoordinate(1) - center.at(1);
        y02 = nodeB->giveCoordinate(2) - center.at(2);
        z02 = nodeB->giveCoordinate(3) - center.at(3);

        // B matrix in local coordinates (and without the term 1/length)

        Bloc.zero();

        Bloc.at(1, 1) =  -1.;
        Bloc.at(2, 2) =  -1.;
        Bloc.at(3, 3) =  -1.;

        Bloc.at(1, 5) =   z01;
        Bloc.at(1, 6) =  -y01;
        Bloc.at(2, 4) =  -z01;
        Bloc.at(2, 6) =   x01;
        Bloc.at(3, 4) =   y01;
        Bloc.at(3, 5) =  -x01;

        Bloc.at(1, 7) =   1.;
        Bloc.at(2, 8) =   1.;
        Bloc.at(3, 9) =   1.;

        Bloc.at(1, 11) =  -z02;
        Bloc.at(1, 12) =   y02;
        Bloc.at(2, 10) =   z02;
        Bloc.at(2, 12) =  -x02;
        Bloc.at(3, 10) =  -y02;
        Bloc.at(3, 11) =   x02;

        // Transformation to global coordinates

        answer.resize(3, 12);
        answer.beProductOf(lcs, Bloc);

        // Division by the length

        answer.times(1. / length);

        return;

        break;

    case 3:
        // Coordinate differences
        x01 = nodeA->giveCoordinate(1) - center.at(1);
        y01 = nodeA->giveCoordinate(2) - center.at(2);
        z01 = nodeA->giveCoordinate(3) - center.at(3);
        x02 = nodeB->giveCoordinate(1) + kxa - center.at(1);
        y02 = nodeB->giveCoordinate(2) + kyb - center.at(2);
        z02 = nodeB->giveCoordinate(3) + kzc - center.at(3);

        // B matrix in local coordinates (and without the term 1/length)

        Bloc.zero();

        Bloc.at(1, 1) =  -1.;
        Bloc.at(2, 2) =  -1.;
        Bloc.at(3, 3) =  -1.;

        Bloc.at(1, 5) =   z01;
        Bloc.at(1, 6) =  -y01;
        Bloc.at(2, 4) =  -z01;
        Bloc.at(2, 6) =   x01;
        Bloc.at(3, 4) =   y01;
        Bloc.at(3, 5) =  -x01;

        Bloc.at(1, 7) =   1.;
        Bloc.at(2, 8) =   1.;
        Bloc.at(3, 9) =   1.;

        Bloc.at(1, 11) =  -z02;
        Bloc.at(1, 12) =   y02;
        Bloc.at(2, 10) =   z02;
        Bloc.at(2, 12) =  -x02;
        Bloc.at(3, 10) =  -y02;
        Bloc.at(3, 11) =   x02;

        // Transformation to global coordinates

        FloatMatrix answer2(3, 12);
        answer2.zero();
        answer2.beProductOf(lcs, Bloc);

        // Division by the length

        answer2.times(1. / length);

        // periodic transformation matrix T
        FloatMatrix Tper(12, 18);

        Tper.zero();

        Tper.at(1, 1)     = 1.;
        Tper.at(2, 2)     = 1.;
        Tper.at(3, 3)     = 1.;
        Tper.at(4, 4)     = 1.;
        Tper.at(5, 5)     = 1.;
        Tper.at(6, 6)     = 1.;
        Tper.at(7, 7)     = 1.;
        Tper.at(8, 8)     = 1.;
        Tper.at(9, 9)     = 1.;
        Tper.at(10, 10) = 1.;
        Tper.at(11, 11) = 1.;
        Tper.at(12, 12) = 1.;

        Tper.at(7, 13) = kxa;
        Tper.at(8, 14) = kyb;
        Tper.at(9, 15) = kzc;
        Tper.at(7, 16) = kyb;
        Tper.at(8, 17) = kzc;
        Tper.at(9, 18) = kxa;

        // periodic transformation of Bmatrix
        answer.beProductOf(answer2, Tper);

        return;

        break;
    }
}
Ejemplo n.º 4
0
void TestPaper::question2() {
    std::cout << "11+44=";
    answer2();
}