예제 #1
0
파일: ec.c 프로젝트: calebcase/ec
void
ec_shadow(const char *types[2])
{
    if (ec_type(NULL) == types[0]) {
        ec_type(types[1]);
    }
}
예제 #2
0
bool ht_add(Hash_Table *ht, void *T) {
	if (ec_struct(ht, HTABLE_NAME) || ec_type(T, HTABLE_NAME))
		return false;

	int position = ht_find_position(ht, T);
	Hash_Entry *entry = ht_create_hash_entry(T);
	
	ht->table[position] = entry;
	ht->occupied++;
	
	if ((float) ht->occupied / ht->table_size >= HT_LOAD_FACTOR)
		ht_rehash(ht);
		
	return true;
}
예제 #3
0
void	run(double nbMesures, double moyArith, double moyHarmo, double ecTy)
{
  bool		_end = false;
  t_variable	_var;
  t_result	_res;
  double	nbAdd = 0;
  int		n;
  char		p[SIZE_BUFFER];

  memset(p, '\0', SIZE_BUFFER);
  init_struct(&_var, &_res, nbMesures, moyArith, moyHarmo, ecTy);
  while (!_end)
    {
      nbAdd = write(1, "indtast din vaerdi : ", 21);
      n = read(0, p, SIZE_BUFFER - 1);
      p[n - 1] = '\0';
      if (n > 1 && n < SIZE_BUFFER)
	{
	  if (strncmp("ende", p, n) == 0)
	    _end = true;
	  else if (verif_number(p))
	    {
	      nbAdd = atof(p);
	      moy_arith(&_var, &_res, nbAdd);
	      moy_quadra(&_var, &_res, nbAdd);
	      moy_harmo(&_var, &_res, nbAdd);
	      ec_type(&_var, &_res, nbAdd);
	      printresult(&_res);
	      usleep(500);
	    }
	}
      memset(p, '\0', SIZE_BUFFER);
      init_struct(&_var, &_res, _res.newNbMesures, _res.newMoyArith,
		  _res.newMoyHarmo, _res.newEcTy);
    }
}