int CommonBigNum(int argc, char *const *argv) {

    
	plan_tests(kTestTestCount);

    for(int i=0; i<10; i++) {
        testCreateFree();
        testHexString();
        testData();
        testI();
        testCompare();
        testBitCount();
        testAddSub();
        testAddSubI();
        testShift();
        testMod();
        testModI();
        testModExp();
        testMul();
        testMulI();
        testPrime();
        testDiv();
        testMulMod();
    }

    return 0;
}
Beispiel #2
0
void* threadConsumer(){
	int i, n, flag;

	while(flag < Q){
		n = 0;

		sem_wait(&full);
		sem_wait(&mutex); // Início da SC -------

		for(i=0; i<N; i++) // Seleciona a posição com menor número no buffer
			if((gBuffer[n] > gBuffer[i] && gBuffer[i] != 0) || gBuffer[n] == 0)
				n = i;
		i = n;

		n = gBuffer[i]; // Salva item do buffer
		gBuffer[i] = 0; // Remove item do buffer
		gItens++; // Incrementa a quantidade de itens consumidos
		flag = gItens; // Flag verificadora para usar fora da SC
		printf("\t\t- Removido item %5i \n", n);
		
		sem_post(&mutex); // Fim da SC ----------
		sem_post(&empty);

		if(testPrime(n)) // Consome item (verifica se é primo)
			printf("\t\t- Consumido item %5i (primo)\n", n);
		else
			printf("\t\t- Consumido item %5i \n", n);
	}
	// Quando o último item é consumido, os semaforos são destruídos
	sem_destroy(&full);
	sem_destroy(&empty);
	sem_destroy(&mutex);
	printf("----- Todos os %i números produzidos foram consumidos.\n", Q);
	exit(0); // Encerra o programa, pois os consumidores ficam presos no semaforo
}
Beispiel #3
0
int main(){
  testPrime();
  testDefix();
  testSumSlice();
  testListPrimes();

  return 0;
}
Beispiel #4
0
int main(){
testPrime();
testDefix();
testSumSlice();
testListPrimes();
square(10);
  system("pause");
  
   return 0;
}
Beispiel #5
0
void partitionPrimeHelper(int * part, int ind, int left)
{
     int val;
  int primetest;
  
  if (left == 0)
    {
      printPartition(part, ind);
      return;
    }
  for (val = 1; val <= left; val ++)
    {
      primetest = testPrime(val);  
      if(primetest==1&& val!=1)
	{
	  part[ind] = val;
	  partitionPrimeHelper(part, ind + 1, left - val);
	}
    }
  
}