feat: reformatted code

This commit is contained in:
2021-02-10 18:56:47 +01:00
parent 2b295db30a
commit 90ef4522ca
16 changed files with 47 additions and 38 deletions

View File

@@ -32,12 +32,13 @@ int abs(int val) {
// next stolen form https://www.techiedelight.com/implement-itoa-function-in-c/
// inline function to swap two numbers
void swap(char *x, char *y) {
char t = *x; *x = *y; *y = t;
char t = *x;
*x = *y;
*y = t;
}
// function to reverse buffer[i..j]
char* reverse(char *buffer, int i, int j)
{
char *reverse(char *buffer, int i, int j) {
while (i < j)
swap(&buffer[i++], &buffer[j--]);
@@ -45,8 +46,7 @@ char* reverse(char *buffer, int i, int j)
}
// Iterative function to implement itoa() function in C
char* itoa(int value, char* buffer, int base)
{
char *itoa(int value, char *buffer, int base) {
// invalid input
if (base < 2 || base > 32)
return buffer;
@@ -55,8 +55,7 @@ char* itoa(int value, char* buffer, int base)
int n = abs(value);
int i = 0;
while (n)
{
while (n) {
int r = n % base;
if (r >= 10)