Ejemplo n.º 1
0
	bool isRelOp() const {
		return isEqual() ||
			isNotEqual() ||
			isLessThan() ||
			isGreaterThan() ||
			isLessThanEqual() ||
			isGreaterThanEqual();
	}
Ejemplo n.º 2
0
void test_insert(){
	int i;
	struct node_avl * p = NULL;

	DESCRIBE("INSERE ELEMENTOS");
	WHEN("Eu insiro elementos");
	IF("Insiro um número razoável MAX");
	THEN("Deve inserir todos");
	for(i=1; i<=MAX; i++){
		struct node_avl * new_root = avl_insert(p,i);
		isNotNull(new_root);
		p = new_root;
	}

	THEN("Deve não estar vazia");
	isNotEqual(avl_height(p),0);


	THEN("Deve encontrar todas as chaves inseridas");
	
	for(i=1; i<=MAX; i++){
		isNotNull(avl_search(p,i));
		
	}

	THEN("Alturas da subárvore direita e esquerda não podem ter diferença maior que 1");
	if (p){
		int left, right, diff;
		left = avl_height(p->left);
		right = avl_height(p->right);
		diff = left>right?left-right:right-left;
		diff = diff>1? 0:1;
		isNotEqual(diff,0);
	}
	else isNotNull(NULL);

	THEN("Consegue imprimir INFIX");
	avl_print_infix(p);

	avl_destroy(p);
}
vector<vector<int> > permute(vector<int>& nums)
{
	vector<int> initNums = nums;
	vector<vector<int> > res;

	do
	{
		nextPermutation(nums);
		res.push_back(nums);

	} while (!isNotEqual(nums, initNums));

	return res;
}
/* *******Function to find factorial of number****** */
int* factorial (int* num ,int numSize) {
     int *tmp ,*fact ,a [1] = {1};  //a is small array.it just keep 1 and acts as the loop counter.
     tmp = (int*) calloc ( sizeof (int), 1);  //tmp array contains the number upto where factorial has been calculated in the loop.
     fact = (int*) calloc ( sizeof (int), 1);  //fact array contains actual factorial of the number
     tmp [0] = 1;
     fact[0] = 1;   
       
     while ( isNotEqual ( num, numSize, tmp, sumSize)) {
       tmp = bigAddition (tmp ,sumSize ,a ,1);  //incrementing number
       fact = bigMultiplication ( fact , prodSize ,tmp , sumSize); //multiplying intermediate factorial values.
       }
       return fact;
       
}
Ejemplo n.º 5
0
void Token::print() const {
	if( eol() ) std::cout << "NEWLINE" ;
	else if( eof() ) std::cout << "ENDMARKER" ;
	else if( indent() ) std::cout << "INDENT";
	else if( dedent() ) std::cout << "DEDENT";
	else if( isOpenBrace() ) std::cout << " { ";
	else if( isCloseBrace() ) std::cout << " } ";
	else if( isComma() ) std::cout << " , ";
	else if( isPeriod()) std::cout<< ".";
	else if( isEqual() ) std::cout << " == ";
	else if( isNotEqual() ) std::cout << " != ";
	else if( isLessThan() ) std::cout << " < ";
	else if( isGreaterThan() ) std::cout << " > ";
	else if( isLessThanEqual() ) std::cout << " <= ";
	else if( isGreaterThanEqual() ) std::cout << " >= ";
	else if( isOpenParen() )  std::cout << " ( " ;
	else if( isCloseParen() )  std::cout << " ) " ;
	else if( isAssignmentOperator() )  std::cout << " = ";
	else if( isColon() )  std::cout << " : " ;
	else if( isMultiplicationOperator() )  std::cout << " * " ;
	else if( isAdditionOperator() )  std::cout << " + ";
	else if( isSubtractionOperator() )  std::cout << " - ";
	else if( isModuloOperator() )  std::cout << " % ";
	else if( isDivisionOperator() )  std::cout << " / ";
	else if( isFloorDivision() ) std::cout << " // ";
	else if( isOpenBrack() ) std::cout<< "[";
	else if( isCloseBrack() ) std::cout<< "]";
	else if( isName() )  std::cout << getName();
	else if( isKeyword() ) std::cout << getKeyword();
	else if( isWholeNumber() ) std::cout << getWholeNumber();
	else if( isFloat() ) std::cout << getFloat();
	else if( isString() ) std::cout << getString();
	else if( isCall() ) std::cout << "CALL " << getName();
	else if( isSub() ) std::cout << "ARRAY SUB " << getName();
	else if( isAppend() ) std::cout << "ARRAY APPEND " << getName();
	else if( isPop() ) std::cout << "ARRAY POP " << getName();
	else std::cout << "Uninitialized token.\n";
}
Ejemplo n.º 6
0
bool operator!=(bigInt a, bigInt b) {
	return isNotEqual(a, b);
}
Ejemplo n.º 7
0
bool Color::operator!=(const Color& color) noexcept
{
    return isNotEqual(color, true);
}