int main(void)
{
	unsigned long a, b, c, d;

	printf("\n.constants:\n");
	a = get_remainder(CRC, 32, 128);
	b = get_remainder(CRC, 32, 96);
	c = get_remainder(CRC, 32, 64);
	d = get_remainder(CRC, 32, 32);
	print_four_remainders(a, 128, b, 96, c, 64, d, 32, "");
	printf("\t/* Barrett constant m - (4^32)/n */\n");
	print_quotient(get_quotient(CRC, 32, 64), 64, "");
	printf("\t/* Barrett constant n */\n");
	printf("\t.octa 0x%032lx\n", CRC_FULL);
	printf("\t.octa 0x0F0E0D0C0B0A09080706050403020100\t/* byte reverse permute constant */\n");

	printf("\n.bit_reflected_constants:\n");
	a = reflect(get_remainder(CRC, 32, 32), 32);
	b = reflect(get_remainder(CRC, 32, 64), 32);
	c = reflect(get_remainder(CRC, 32, 96), 32);
	d = reflect(get_remainder(CRC, 32, 128), 32);
	print_four_remainders(a, 32, b, 64, c, 96, d, 128, "`");
	printf("\t/* 33 bit reflected Barrett constant m - (4^32)/n */\n");
	print_quotient(reflect(get_quotient(CRC, 32, 64), 33), 64, "`");
	printf("\t/* 33 bit reflected Barrett constant n */\n");
	printf("\t.octa 0x%032lx\n", reflect(CRC_FULL, 33));
	printf("\t/* byte reverse permute constant */\n");
	printf("\t.octa 0x0F0E0D0C0B0A09080706050403020100\n");

	return 0;
}
示例#2
0
文件: greedy.c 项目: ahairshi/cs50
int main(int argc, char *argv[])
{
    // Get the amount of change from user
    float amount;
    
    int cents_amount;
    int coins_total = 0;
        
    amount = read_input("O hai! How much change is owed?");
    
    // Convert the amount of money to integer value of total cents
    cents_amount = round(amount * 100);
    
    // Now check how much quarters, dimes and nickels are needed
    coins_total = coins_total + get_quotient(&cents_amount, 25);
    coins_total = coins_total + get_quotient(&cents_amount, 10);
    coins_total = coins_total + get_quotient(&cents_amount, 5);
    
    coins_total = coins_total + cents_amount;   // Only pennies are left
    
    // Now print the result
    printf("%d\n", coins_total);
    
    return 0;
}