예제 #1
0
파일: 8.c 프로젝트: vinayvinodmarar/K-R
void lower_case(char s[]) {
	double op1,op2;
	if(strcmp(s, "pow") == 0) {
		push(pow(pop(), pop()));
	}
	if(strcmp(s, "sin") == 0) {
		push(sin(pop()));
	}
	if(strcmp(s, "cos") == 0) {
		push(cos(pop()));
	}
	if(strcmp(s, "tan") == 0) {
		push(tan(pop()));
	}
	if(strcmp(s, "p") == 0) {
		printt();
	}
	if(strcmp(s, "c") == 0) {
		my_clear();
	}
	if(strcmp(s, "s") == 0) {
		op2 = pop();
		op1 = pop();
		push(op2);
		push(op1);
	}
	if(strcmp(s, "d") == 0) {
		op2 = pop();
		push(op2);
		push(op2);
	}
}
예제 #2
0
void    end_game(char **_tab, t_cursor *cursor, char *name)
{
  if (player_win(_tab))
    {
      my_clear();
      free_tab(_tab);
      free(cursor);
      my_putstr("Game just ended, ");
      my_putstr(name);
      my_putstr(" won this game.\n");
      exit(0);
    }
}
예제 #3
0
파일: my.c 프로젝트: macroxue/const-pi
unsigned long my_div_estimate_threshold()
{
    const double log10 = 3.321928;
    clock_t begin, end, diff1, diff2;
    mpz_t y, x;
    unsigned long digits = 100, min_digits, max_digits, prec, stage = 1;
    div_threshold = 0;
    for (;;) {
        if (stage == 1)
            digits *= 2;
        else
            digits = (min_digits + max_digits)/2;
        prec = (unsigned long) (digits * log10) + 32;
        my_init(prec);
        mpz_init(y);
        mpz_init(x);
        mpz_ui_pow_ui(y, 10, digits);
        mpz_ui_pow_ui(x, 10, digits/10);
        begin = clock();
        my_divexact(y, y, x);
        end = clock();
        diff1 = end - begin;

        mpz_ui_pow_ui(y, 10, digits);
        begin = clock();
        mpz_divexact(y, y, x);
        end = clock();
        diff2 = end - begin;
        my_clear();
        mpz_clear(y);
        mpz_clear(x);

        printf("digits %ld, my %ld, mpz %ld\n", digits, diff1, diff2);
        if (stage == 1) {
            if (diff1 >= 10 && diff1 < diff2) {
                stage = 2;
                min_digits = digits/2;
                max_digits = digits;
            }
        } else {
            if (diff1 < diff2)
                max_digits = digits;
            else
                min_digits = digits;
            if (max_digits - min_digits < 100)
                break;
        }
    }
    return (unsigned long) (digits * log10);
}
예제 #4
0
int	my_collision(int *first, int *second, int y, WINDOW *window)
{
  if (my_check_col(first, y) != 2)
    {
      flash();
      return -1;
    }
  if (my_check_object(first, y) == -1)
    {
      flash();
      return -1;
    }
  my_check_bonus(second, first, y);
  my_clear(first, y);
}
예제 #5
0
파일: start_shell.c 프로젝트: girards/42sh
int		start_shell(t_42sh *shell)
{
  t_token	*token;
  int		fd;

  fd = creat(".hist42sh", 0644);
  if ((my_clear() == -1))
    return (-42);
  while (1)
    {
      token = NULL;
      signal(SIGINT, get_sigint);
      prompt(shell);
      shell->cmd = read_line(fd);
      if (lexer(shell->cmd, &token, shell) == -42)
	return (-42);
      free_my_tok(token);
    }
  return (0);
}
예제 #6
0
void	aff_rules(int r)
{
  my_clear();
  my_putstr_blue("         Welcome in Allum1 game!\n\n");
  my_putstr_blue("You are playing with ");
  my_put_nbr_blue(r);
  my_putstr_blue(" raws of allums\n\n");
  my_putstr_blue("To win, you have to NOT pick the last allum\n");
  my_putstr_blue("You can pick between one allum and an entire raw\n\n");
  my_putstr_blue("\rGame launching in 5..");
  usleep(1000000);
  my_putstr_blue("\rGame launching in 4..");
  usleep(1000000);
  my_putstr_blue("\rGame launching in 3..");
  usleep(1000000);
  my_putstr_blue("\rGame launching in 2..");
  usleep(1000000);
  my_putstr_blue("\rGame launching in 1..");
  usleep(1000000);
}