Exemple #1
0
/*
 * collect income tax
 */
void
inc_tax(void)
{
	int worth, com_num;

	com_num = getinp("Do you wish to lose 10% of your total worth or "
	    "$200? ", perc);
	worth = cur_p->money + prop_worth(cur_p);
	printf("You were worth $%d", worth);
	worth /= 10;
	if (com_num > 2) {
		if (worth < 200)
			printf(".  Good try, but not quite.\n");
		else if (worth > 200)
			lucky(".\nGood guess.  ");
		cur_p->money -= 200;
	}
	else {
		printf(", so you pay $%d", worth);
		if (worth > 200)
			printf("  OUCH!!!!.\n");
		else if (worth < 200)
			lucky("\nGood guess.  ");
		cur_p->money -= worth;
	}
	if (worth == 200)
		lucky("\nIt makes no difference!  ");
}
Exemple #2
0
Fichier : 4.cpp Projet : Jy-Liu/ADA
int main(int argc, char* argv[]) {
  int T;
  scanf("%d", &T);
  long long int l, r;
  find(18, 0, 0, 0);
  for (int i = 0; i < T; i++) {
    scanf("%lld%lld", &l, &r);
    printf("%lld\n", lucky(r+1)-lucky(l));
  }
  return 0;
}
int main(){

    int u, x, y; scanf("%d %d %d", &u, &x, &y);

    int res = (x % 50);
    while(res < y || !lucky(res, u)){res += 50;}
    printf("%d\n", (res <= x) ? 0 : (res - x + 99) / 100);
    return 0;
}
Exemple #4
0
bool luckyK(int p, int k) {
	int tmp;
	int cnt = 0;
	while (p > 0) {
		tmp =  p % 10;
		if (lucky(tmp)) {
			cnt ++;
		}
		p = p / 10;
	}
	if (cnt > k ) return false;
	else return true;
}
int main(int argc, char **argv){
	int i;
	for (i=1; i<argc; i++)
	{
		if (lucky(argv[i]) == 1)
			printf("true");
		else
			printf("false");
		if (i<argc-1)
			printf(" ");
	}
	printf("\n");
	return 0;
}