48 lines
1.5 KiB
C
48 lines
1.5 KiB
C
#include <stdio.h>
|
|
#include <malloc.h>
|
|
#include "PointersLibs.h"
|
|
|
|
|
|
BOOLEAN SentenceALowerThenSentenceB(char *ptr_sentence_a, char *ptr_sentence_b)
|
|
{
|
|
while (*(ptr_sentence_a++) == *(ptr_sentence_b++) && *ptr_sentence_a && *ptr_sentence_b);
|
|
|
|
return ((*(--ptr_sentence_a) <= *(--ptr_sentence_b)));
|
|
}
|
|
|
|
void SwapPointers(char **first_pointer, char **second_pointer)
|
|
{
|
|
char *temp_pointer = *first_pointer;
|
|
*first_pointer = *second_pointer;
|
|
*second_pointer = temp_pointer;
|
|
}
|
|
|
|
void SortStringAsDictionary(char **ptr_vec, unsigned short lenght)
|
|
{
|
|
char **low_sentence = ptr_vec;
|
|
unsigned short counter_loop1, counter_loop2;
|
|
for (counter_loop1 = ZERO; counter_loop1 < lenght; counter_loop1++)
|
|
{
|
|
for (counter_loop2 = counter_loop1; counter_loop2 < lenght; counter_loop2++)
|
|
{
|
|
(SentenceALowerThenSentenceB(*ptr_vec ,*low_sentence) ? ZERO : SwapPointers(ptr_vec, low_sentence));
|
|
*low_sentence = LastCharOfString(*low_sentence);
|
|
}
|
|
*ptr_vec = LastCharOfString(*ptr_vec) + ONE;
|
|
*low_sentence = *ptr_vec;
|
|
}
|
|
}
|
|
// --------------------------------------------------------------------------------------
|
|
// Exe 5
|
|
// -----
|
|
//
|
|
//
|
|
//---------------------------------------------------------------------------------------
|
|
// Proggramer : Cohen Idan
|
|
// Student No : 211675038
|
|
// Date : 21.11.19
|
|
//---------------------------------------------------------------------------------------
|
|
void main(void)
|
|
{
|
|
|
|
} |