41 lines
1.3 KiB
C
41 lines
1.3 KiB
C
#include <stdio.h>
|
|
|
|
#define ZERO 0
|
|
//---------------------------------------------------------------------------------------
|
|
// Exercise 7
|
|
// ----------
|
|
//
|
|
// General : The program prints the minimum number of tiles required to
|
|
// line the length of the line.
|
|
//
|
|
// Input : A(number), B(number), N(number).
|
|
//
|
|
// Process : The program דubtracts A by N until the remainder of B by N is 0.
|
|
//
|
|
// Output : Count of A and count of B.
|
|
//
|
|
//---------------------------------------------------------------------------------------
|
|
// Programmer : Cohen Idan
|
|
// Student No : None
|
|
// Date : 23.09.2019
|
|
//---------------------------------------------------------------------------------------
|
|
void main(void)
|
|
{
|
|
unsigned short a,
|
|
b,
|
|
n,
|
|
counter,
|
|
count_a = ZERO,
|
|
count_b = ZERO;
|
|
|
|
printf("Enter A: ");
|
|
scanf("%hu", &a);
|
|
printf("Enter B: ");
|
|
scanf("%hu", &b);
|
|
printf("Enter N: ");
|
|
scanf("%hu", &n);
|
|
|
|
for (counter = n; counter; (!(counter % b)) ? (count_b = counter / b, counter %= b) : (count_a++, counter -= a));
|
|
|
|
printf("Count A: %hu\nCount B: %hu\n", count_a, count_b);
|
|
} |