i wrote out what i could but when i enter 45/56 it messes up and i am having trouble checking the next number.
Code:
#include <stdio.h>
#define MAX 16
int digit[MAX], x, y, z, a, j, k, q;
double decimal;
float n, d;
void function( int h[], int p, int f);
int main()
{
printf("Enter N/D: ");
scanf("%f/%f", &n, &d);
decimal = n / d;
a = n;
q = d;
printf("%d / %d = %lf ", a, q, decimal);
for ( x = 0; x < MAX; x++)
{
digit[x] = (int)(decimal * 10);
decimal = decimal * 10 - digit[x];
}
for( z = 0; z< MAX; y++)
{
for ( y = 1; y < MAX; y++)
{
if( digit[z] == digit[y])/*this is where it finds the first two matching number*/
/*
k = z + 1; i decide to add one to z and one to k to see if the next number was repeating
j = y + 1; so 45/56 would work. when i do this though the program doesnt work correctly
if (digit[k] == digit[j])this is supposed to check the next number after it*/
function( digit, y, z);/*if it is repeating then it continues on with the function*/
}
}
printf("\n");
system("PAUSE");
return 0;
}
void function( int h[], int p, int f)
{
int i;
printf("or .");
for (i = 0; i < f; i++)
{
printf("%d", h[i]);
}
printf("(");
for ( i = f; i < p; i++)
{
printf("%d", h[i]);
}
printf(")\n");
system("Pause");
exit(1);
}