TestResult* digitsCountTestNegativeNumber() { int x = -1; int expected = 1; int actual = digitsCount(x); TestResult* r = malloc(sizeof(TestResult)); r -> testName = "digitsCountTestNegativeNumber"; r -> passed = areIntEqual(actual, expected); return r; }
void main() { int term1[1000], term2[1000]; int i; for(i = 0;i < 999;i++) { term1[i] = 0; term2[i] = 0; } term1[999] = 1; term2[999] = 1; for(i = 3;!digitsCount(term2);i++) addAndCopy(term1, term2); printf("solution: %d\n",i - 1); }
char* convertIntToString(int x) { int length = digitsCount(x) + 1; if (x < 0) { length++; } char* string = malloc(length * sizeof(char)); int i; int d; for (i = length - 2, d = abs(x); i >= 0; i--, d /= 10) { string[i] = convertDigitToChar(d % 10); } string[length - 1] = '\0'; if (x < 0) { string[0] = '-'; } return string; }