36 lines
823 B
C
36 lines
823 B
C
|
#include <stdio.h>
|
||
|
#include <stdlib.h>
|
||
|
int main(void)
|
||
|
{
|
||
|
int numerateur = 0;
|
||
|
int denominateur = 0;
|
||
|
int quotient = 0;
|
||
|
printf("Saisissez un entier : ");
|
||
|
scanf("%d", &numerateur);
|
||
|
printf("Saisissez un entier strictement positif : ");
|
||
|
scanf("%d", &denominateur);
|
||
|
if (numerateur >= 0)
|
||
|
{
|
||
|
while (numerateur >= denominateur)
|
||
|
{
|
||
|
numerateur -= denominateur;
|
||
|
quotient += 1;
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
while (numerateur < 0)
|
||
|
{
|
||
|
numerateur += denominateur;
|
||
|
quotient -= 1;
|
||
|
}
|
||
|
}
|
||
|
printf("%d", quotient * denominateur + numerateur);
|
||
|
printf(" = ");
|
||
|
printf("%d", quotient);
|
||
|
printf(" x ");
|
||
|
printf("%d", denominateur);
|
||
|
printf(" + ");
|
||
|
printf("%d\n", numerateur);
|
||
|
return EXIT_SUCCESS;
|
||
|
}
|