First Upload
This commit is contained in:
41
4/ex7.c
Normal file
41
4/ex7.c
Normal file
@@ -0,0 +1,41 @@
|
||||
#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);
|
||||
}
|
||||
Reference in New Issue
Block a user