First Upload
This commit is contained in:
1188
9/IdanLib.h
Normal file
1188
9/IdanLib.h
Normal file
File diff suppressed because it is too large
Load Diff
BIN
9/IdanStringLib
Normal file
BIN
9/IdanStringLib
Normal file
Binary file not shown.
452
9/IdanStringLib.h
Normal file
452
9/IdanStringLib.h
Normal file
@@ -0,0 +1,452 @@
|
||||
#define DAYS_IN_MONTH 30
|
||||
#define MONTHS_IN_YEAR 12
|
||||
#define ONE_HUNDRED 100
|
||||
#define ONE_THOSEND 10000
|
||||
#define BOOLEAN unsigned short
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
#define TEN 10
|
||||
#define TWELVE 12
|
||||
#define THIRTY 30
|
||||
#define ZERO 0
|
||||
#define ONE 1
|
||||
#define TWO 2
|
||||
#define THREE 3
|
||||
#define FOUR 4
|
||||
#define TAKE_SIGNED(x) (((2 * (x)) + 1) % 2)
|
||||
#define ABS(x) (x) * (((2 * (x)) + 1) % 2)
|
||||
#define MAX(x, y) (x > y) ? x : y
|
||||
#define MIN(x, y) (x < y) ? x : y
|
||||
#define BACKSLASH_ZERO '\0'
|
||||
|
||||
//---------------------------------------------------------------------------------------
|
||||
// CharInString
|
||||
// ------------
|
||||
//
|
||||
// General :CHecks if the char exist in string.
|
||||
//
|
||||
// Parameters :
|
||||
// text - string (char[])
|
||||
// c - char (char)
|
||||
//
|
||||
// Return value : If the char exist in string (BOOLEAN).
|
||||
//
|
||||
//---------------------------------------------------------------------------------------
|
||||
// Programmer : Cohen Idan
|
||||
// Student No : 211675038
|
||||
// Date : 04.10.2019
|
||||
//---------------------------------------------------------------------------------------
|
||||
BOOLEAN CharInString(char text[], char c)
|
||||
{
|
||||
BOOLEAN exist = FALSE;
|
||||
unsigned short counter = ZERO;
|
||||
while ((text[counter] != c) * text[counter++]);
|
||||
exist = (text[--counter] == c);
|
||||
|
||||
return (exist);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------
|
||||
// StringLenght
|
||||
// ------------
|
||||
//
|
||||
// General : Checks the lenght of string.
|
||||
//
|
||||
// Parameters :
|
||||
// text - string (char[])
|
||||
//
|
||||
// Return value : Lenght of string (unsigned short).
|
||||
//
|
||||
//---------------------------------------------------------------------------------------
|
||||
// Programmer : Cohen Idan
|
||||
// Student No : None
|
||||
// Date : 04.10.2019
|
||||
//---------------------------------------------------------------------------------------
|
||||
unsigned short StringLenght(char text[])
|
||||
{
|
||||
unsigned short counter = ZERO;
|
||||
while (text[counter++]);
|
||||
|
||||
return (--counter);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------
|
||||
// StringCompare
|
||||
// ------------------------
|
||||
//
|
||||
// General : Compare 2 strings.
|
||||
//
|
||||
// Parameters :
|
||||
// text1 - string (char[])
|
||||
// text2 - string (char[])
|
||||
//
|
||||
// Return value : If this 2 strings are equals (BOOLEAN).
|
||||
//
|
||||
//---------------------------------------------------------------------------------------
|
||||
// Programmer : Cohen Idan
|
||||
// Student No : 211675038
|
||||
// Date : 04.10.2019
|
||||
//---------------------------------------------------------------------------------------
|
||||
BOOLEAN StringCompare(char text1[], char text2[])
|
||||
{
|
||||
BOOLEAN equals = FALSE;
|
||||
unsigned short counter = ZERO;
|
||||
while ((text1[counter] == text2[counter]) * (text1[counter++]));
|
||||
equals = (text1[--counter] == text2[counter]);
|
||||
|
||||
return equals;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------
|
||||
// IndexCharInString
|
||||
// -----------------
|
||||
//
|
||||
// General : Find the index of char in the string.
|
||||
//
|
||||
// Parameters :
|
||||
// text - string (char[])
|
||||
// c - char (char)
|
||||
//
|
||||
// Return value : The first index of the char in the string (unsigned short).
|
||||
//
|
||||
//---------------------------------------------------------------------------------------
|
||||
// Programmer : Cohen Idan
|
||||
// Student No : 211675038
|
||||
// Date : 04.10.2019
|
||||
//---------------------------------------------------------------------------------------
|
||||
unsigned short IndexCharInString(char text[], char c)
|
||||
{
|
||||
unsigned short counter = ZERO;
|
||||
while (text[counter++] != c);
|
||||
|
||||
return (--counter);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------
|
||||
// CountCharInString
|
||||
// -----------------
|
||||
//
|
||||
// General : Count how many the char is in the string.
|
||||
//
|
||||
// Parameters :
|
||||
// text - string (char[])
|
||||
// c - char (char)
|
||||
//
|
||||
// Return value : Count of char in the string (unsigned short).
|
||||
//
|
||||
//---------------------------------------------------------------------------------------
|
||||
// Programmer : Cohen Idan
|
||||
// Student No : None
|
||||
// Date : 04.10.2019
|
||||
//---------------------------------------------------------------------------------------
|
||||
unsigned short CountCharInString(char text[], char c)
|
||||
{
|
||||
unsigned short count = ZERO,
|
||||
loop_counter = ZERO;
|
||||
while (text[loop_counter])
|
||||
{
|
||||
count += (text[loop_counter++] == c);
|
||||
}
|
||||
|
||||
return (count);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------
|
||||
// CutString
|
||||
// ---------
|
||||
//
|
||||
// General : Cut the string.
|
||||
//
|
||||
// Parameters :
|
||||
// text - string (char[])
|
||||
// start - from where (unsigned short)
|
||||
// size - the size of cut (unsigned short)
|
||||
//
|
||||
// Return value : If the equation is ok (BOOLEAN).
|
||||
//
|
||||
//---------------------------------------------------------------------------------------
|
||||
// Programmer : Cohen Idan
|
||||
// Student No : None
|
||||
// Date : 04.10.2019
|
||||
//---------------------------------------------------------------------------------------
|
||||
void CutString(char text[], unsigned short start, unsigned short size)
|
||||
{
|
||||
unsigned short counter;
|
||||
for (counter = ZERO; (counter < size) * text[counter + start]; counter++)
|
||||
{
|
||||
text[counter] = text[counter + start];
|
||||
}
|
||||
text[counter] = BACKSLASH_ZERO;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------
|
||||
// CopyString
|
||||
// ----------
|
||||
//
|
||||
// General : Copy second string into first string.
|
||||
//
|
||||
// Parameters :
|
||||
// text - first text (char[])
|
||||
// copy - second text (char[])
|
||||
// start - from where to start (unsigned short)
|
||||
//
|
||||
// Return value : None.
|
||||
//
|
||||
//---------------------------------------------------------------------------------------
|
||||
// Programmer : Cohen Idan
|
||||
// Student No : 211675038
|
||||
// Date : 04.10.2019
|
||||
//---------------------------------------------------------------------------------------
|
||||
void CopyString(char text[], char copy[], unsigned short start)
|
||||
{
|
||||
unsigned short counter,
|
||||
length = StringLenght(copy) + start;
|
||||
for (counter = start; counter < length; counter++)
|
||||
{
|
||||
text[counter] = copy[counter - start];
|
||||
}
|
||||
text[counter] = BACKSLASH_ZERO;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------
|
||||
// LinkingString
|
||||
// -------------
|
||||
//
|
||||
// General : Copy second string into end of first string.
|
||||
//
|
||||
// Parameters :
|
||||
// textA - first text (char[])
|
||||
// textB - second text (char[])
|
||||
//
|
||||
// Return value : None.
|
||||
//
|
||||
//---------------------------------------------------------------------------------------
|
||||
// Programmer : Cohen Idan
|
||||
// Student No : 211675038
|
||||
// Date : 04.10.2019
|
||||
//---------------------------------------------------------------------------------------
|
||||
void LinkingString(char textA[], char textB[])
|
||||
{
|
||||
CopyString(textA, textB, StringLenght(textA));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------
|
||||
// ReverseString
|
||||
// -------------
|
||||
//
|
||||
// General : Chnage to oppsite the string.
|
||||
//
|
||||
// Parameters :
|
||||
// textA - first text (char[])
|
||||
//
|
||||
// Return value : None.
|
||||
//
|
||||
//---------------------------------------------------------------------------------------
|
||||
// Programmer : Cohen Idan
|
||||
// Student No : 211675038
|
||||
// Date : 04.10.2019
|
||||
//---------------------------------------------------------------------------------------
|
||||
void ReverseString(char textA[])
|
||||
{
|
||||
unsigned short textA_lenght = StringLenght(textA) - ONE,
|
||||
counter,
|
||||
loop_lenght = (textA_lenght + ONE) / TWO;
|
||||
char temp_char;
|
||||
for (counter = ZERO; counter < loop_lenght; counter++)
|
||||
{
|
||||
temp_char = textA[counter];
|
||||
textA[counter] = textA[textA_lenght - counter];
|
||||
textA[textA_lenght - counter] = temp_char;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------
|
||||
// StringBInStringA
|
||||
// ----------------
|
||||
//
|
||||
// General : Check if string B exists in string A.
|
||||
//
|
||||
// Parameters :
|
||||
// textA - first text (char[])
|
||||
// textB - second text (char[])
|
||||
//
|
||||
// Return value : If string B exists in string A (BOOLEAN).
|
||||
//
|
||||
//---------------------------------------------------------------------------------------
|
||||
// Programmer : Cohen Idan
|
||||
// Student No : 211675038
|
||||
// Date : 04.10.2019
|
||||
//---------------------------------------------------------------------------------------
|
||||
BOOLEAN StringBInStringA(char textA[], char textB[])
|
||||
{
|
||||
BOOLEAN exist = FALSE;
|
||||
unsigned short textA_lenght = StringLenght(textA);
|
||||
unsigned short textB_lenght = StringLenght(textB);
|
||||
char temp_textA[textA_lenght];
|
||||
unsigned short counter;
|
||||
unsigned short loop_length = StringLenght(textA) - textB_lenght;
|
||||
for (counter = ZERO; (counter < loop_length) * !exist; counter++)
|
||||
{
|
||||
CopyString(temp_textA, textA, ZERO);
|
||||
CutString(temp_textA, counter, textB_lenght);
|
||||
exist = StringCompare(temp_textA, textB);
|
||||
}
|
||||
|
||||
return (exist);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------
|
||||
// StringBInStringA
|
||||
// ----------------
|
||||
//
|
||||
// General : Find the index of string B in string A.
|
||||
//
|
||||
// Parameters :
|
||||
// textA - first text (char[])
|
||||
// textB - second text (char[])
|
||||
//
|
||||
// Return value : Index of string B in string A (unsigned short).
|
||||
//
|
||||
//---------------------------------------------------------------------------------------
|
||||
// Programmer : Cohen Idan
|
||||
// Student No : 211675038
|
||||
// Date : 04.10.2019
|
||||
//---------------------------------------------------------------------------------------
|
||||
unsigned short IndexStringBInStringA(char textA[], char textB[])
|
||||
{
|
||||
BOOLEAN exist = FALSE;
|
||||
unsigned short textA_lenght = StringLenght(textA);
|
||||
unsigned short textB_lenght = StringLenght(textB);
|
||||
char temp_textA[textA_lenght];
|
||||
unsigned short counter;
|
||||
unsigned short loop_length = StringLenght(textA) - textB_lenght + ONE;
|
||||
for (counter = ZERO; (counter < loop_length) * !exist; counter++)
|
||||
{
|
||||
CopyString(temp_textA, textA, ZERO);
|
||||
CutString(temp_textA, counter, textB_lenght);
|
||||
exist = StringCompare(temp_textA, textB);
|
||||
}
|
||||
|
||||
return (--counter);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------
|
||||
// CountStringBInStringA
|
||||
// ---------------------
|
||||
//
|
||||
// General : Count string B in string A.
|
||||
//
|
||||
// Parameters :
|
||||
// textA - first text (char[])
|
||||
// textB - second text (char[])
|
||||
//
|
||||
// Return value : Count of string B in string A (unsigned short).
|
||||
//
|
||||
//---------------------------------------------------------------------------------------
|
||||
// Programmer : Cohen Idan
|
||||
// Student No : 211675038
|
||||
// Date : 04.10.2019
|
||||
//---------------------------------------------------------------------------------------
|
||||
unsigned short CountStringBInStringA(char textA[], char textB[])
|
||||
{
|
||||
unsigned short count = ZERO;
|
||||
unsigned short textA_lenght = StringLenght(textA);
|
||||
unsigned short textB_lenght = StringLenght(textB);
|
||||
char temp_textA[textA_lenght];
|
||||
unsigned short counter;
|
||||
unsigned short loop_length = StringLenght(textA) - textB_lenght;
|
||||
for (counter = ZERO; (counter < loop_length); counter++)
|
||||
{
|
||||
CopyString(temp_textA, textA, ZERO);
|
||||
CutString(temp_textA, counter, textB_lenght);
|
||||
count += StringCompare(temp_textA, textB);
|
||||
}
|
||||
|
||||
return (count);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------
|
||||
// CountStringBInStringA
|
||||
// ---------------------
|
||||
//
|
||||
// General : Remove first string B from string A.
|
||||
//
|
||||
// Parameters :
|
||||
// textA - first text (char[])
|
||||
// textB - second text (char[])
|
||||
//
|
||||
// Return value : None.
|
||||
//
|
||||
//---------------------------------------------------------------------------------------
|
||||
// Programmer : Cohen Idan
|
||||
// Student No : 211675038
|
||||
// Date : 04.10.2019
|
||||
//---------------------------------------------------------------------------------------
|
||||
void RemoveStringBFromStringA(char textA[], char textB[])
|
||||
{
|
||||
unsigned short textA_lenght = StringLenght(textA);
|
||||
unsigned short textB_lenght = StringLenght(textB);
|
||||
unsigned short index_textB_in_textA = IndexStringBInStringA(textA, textB);
|
||||
char temp_textA[textA_lenght];
|
||||
|
||||
CopyString(temp_textA, textA, ZERO);
|
||||
CutString(temp_textA, index_textB_in_textA + textB_lenght,
|
||||
textA_lenght - (index_textB_in_textA + textB_lenght));
|
||||
CopyString(textA, temp_textA, index_textB_in_textA);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------
|
||||
// CountStringBInStringA
|
||||
// ---------------------
|
||||
//
|
||||
// General : Remove ALL string B from string A.
|
||||
//
|
||||
// Parameters :
|
||||
// textA - first text (char[])
|
||||
// textB - second text (char[])
|
||||
//
|
||||
// Return value : None.
|
||||
//
|
||||
//---------------------------------------------------------------------------------------
|
||||
// Programmer : Cohen Idan
|
||||
// Student No : 211675038
|
||||
// Date : 04.10.2019
|
||||
//---------------------------------------------------------------------------------------
|
||||
void RemoveAllStringBFromStringA(char textA[], char textB[])
|
||||
{
|
||||
unsigned short loop_lenght = CountStringBInStringA(textA, textB);
|
||||
unsigned short counter;
|
||||
for (counter = ZERO; counter < loop_lenght; counter++)
|
||||
{
|
||||
RemoveStringBFromStringA(textA, textB);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------
|
||||
// ValidParenthesesTemplate
|
||||
// ------------------------
|
||||
//
|
||||
// General : checks if the string is a good equation.
|
||||
//
|
||||
// Parameters :
|
||||
// text - string (char[])
|
||||
//
|
||||
// Return value : If the equation is ok (BOOLEAN).
|
||||
//
|
||||
//---------------------------------------------------------------------------------------
|
||||
// Programmer : Cohen Idan
|
||||
// Student No : 211675038
|
||||
// Date : 04.10.2019
|
||||
//---------------------------------------------------------------------------------------
|
||||
BOOLEAN ValidParenthesesTemplate(char text[])
|
||||
{
|
||||
unsigned short counter = ZERO;
|
||||
short count_parenthesis = ZERO;
|
||||
while (text[counter] * (count_parenthesis + ONE))
|
||||
{
|
||||
count_parenthesis += (text[counter] == '(');
|
||||
count_parenthesis -= (text[counter] == ')');
|
||||
}
|
||||
|
||||
return (!count_parenthesis);
|
||||
}
|
||||
35
9/ex1.c
Normal file
35
9/ex1.c
Normal file
@@ -0,0 +1,35 @@
|
||||
#include "IdanStringLib.h"
|
||||
#include "IdanLib.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#define STRING_MAX_SIZE 256
|
||||
|
||||
//---------------------------------------------------------------------------------------
|
||||
// Exercise 1
|
||||
// ----------
|
||||
//
|
||||
// General : The program deletes a string in a string till the are no more.
|
||||
//
|
||||
// Input : 2 string.
|
||||
//
|
||||
// Process : The program checks if the is the string that needs too be deleted if there
|
||||
// is delete else stop and print how many times it was deleted and the new
|
||||
// string.
|
||||
//
|
||||
// Output : The new string and how many times it deleted.
|
||||
//
|
||||
//---------------------------------------------------------------------------------------
|
||||
// Programmer : Cohen Idan
|
||||
// Student No : 211675038
|
||||
// Date : 04.11.2019
|
||||
//---------------------------------------------------------------------------------------
|
||||
void main(void)
|
||||
{
|
||||
typedef char string[STRING_MAX_SIZE];
|
||||
string str1 = "";
|
||||
string str2 = "";
|
||||
|
||||
printf("Count: %u\n", CountStringBInStringA(str1, str2));
|
||||
RemoveAllStringBFromStringA(str1, str2);
|
||||
printf("The text: %s\n", str1);
|
||||
}
|
||||
33
9/ex2.c
Normal file
33
9/ex2.c
Normal file
@@ -0,0 +1,33 @@
|
||||
#include "IdanStringLib.h"
|
||||
#include "IdanLib.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#define STRING_MAX_SIZE 256
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------
|
||||
// Exercise 2
|
||||
// ----------
|
||||
//
|
||||
// General : The program checks if the string is a good equation.
|
||||
//
|
||||
// Input : String.
|
||||
//
|
||||
// Process : The program checks how many times a barcket '(' and a bracket ')' is in the
|
||||
// string and if the first one is a closer.
|
||||
//
|
||||
// Output : If the equation is ok.
|
||||
//
|
||||
//---------------------------------------------------------------------------------------
|
||||
// Programmer : Cohen Idan
|
||||
// Student No : 211675038
|
||||
// Date : 04.11.2019
|
||||
//---------------------------------------------------------------------------------------
|
||||
void main(void)
|
||||
{
|
||||
typedef char string[STRING_MAX_SIZE];
|
||||
string str1 = "";
|
||||
|
||||
ValidParenthesesTemplate(str1);
|
||||
|
||||
}
|
||||
73
9/ex3.c
Normal file
73
9/ex3.c
Normal file
@@ -0,0 +1,73 @@
|
||||
#include "IdanStringLib.h"
|
||||
#include "IdanLib.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#define STRING_MAX_SIZE 256
|
||||
#define A 'a'
|
||||
#define B 'b'
|
||||
|
||||
//---------------------------------------------------------------------------------------
|
||||
// CountStringSubStrings
|
||||
// ------------------------
|
||||
//
|
||||
// General : Checks how many substring can u build with the string that you
|
||||
// get in the main string you got.
|
||||
//
|
||||
// Parameters :
|
||||
// text - string (char[])
|
||||
//
|
||||
// Return value : How many substring can you build (unsigned int).
|
||||
//
|
||||
//---------------------------------------------------------------------------------------
|
||||
// Programmer : Cohen Idan
|
||||
// Student No : 211675038
|
||||
// Date : 04.10.2019
|
||||
//---------------------------------------------------------------------------------------
|
||||
unsigned short CountStringSubStrings(char text[], char a, char b)
|
||||
{
|
||||
unsigned short count = ZERO;
|
||||
unsigned short text_lenght = StringLenght(text);
|
||||
unsigned short temp_text_lenght;
|
||||
char temp_text[text_lenght];
|
||||
unsigned short index_a;
|
||||
|
||||
CopyString(temp_text, text, ZERO);
|
||||
while (CharInString(temp_text, a))
|
||||
{
|
||||
index_a = IndexCharInString(temp_text, a) + ONE;
|
||||
temp_text_lenght = StringLenght(temp_text);
|
||||
CutString(temp_text, index_a, temp_text_lenght - index_a);
|
||||
count += CountCharInString(temp_text, b);
|
||||
}
|
||||
|
||||
return (count);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------
|
||||
// Exercise 3
|
||||
// ----------
|
||||
//
|
||||
// General : The program checks how many substring can u build with the string that you
|
||||
// get in the main string you got.
|
||||
//
|
||||
// Input : String.
|
||||
//
|
||||
// Process : The program checks if there is a char like the start (char start) that the
|
||||
// program got, if there is it will check how many ends (char end) and just
|
||||
// add it too the counter.
|
||||
//
|
||||
// Output : How many substring can you build.
|
||||
//
|
||||
//---------------------------------------------------------------------------------------
|
||||
// Programmer : Cohen Idan
|
||||
// Student No : 211675038
|
||||
// Date : 04.11.2019
|
||||
//---------------------------------------------------------------------------------------
|
||||
void main(void)
|
||||
{
|
||||
typedef char string[STRING_MAX_SIZE];
|
||||
string str1 = "ababbb";
|
||||
|
||||
printf("%u\n", CountStringSubStrings(str1, A, B));
|
||||
|
||||
}
|
||||
68
9/ex4.c
Normal file
68
9/ex4.c
Normal file
@@ -0,0 +1,68 @@
|
||||
#include "IdanStringLib.h"
|
||||
#include "IdanLib.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#define STRING_MAX_SIZE 256
|
||||
|
||||
unsigned short HighestSequence(char vec[])
|
||||
{
|
||||
unsigned short place = ZERO;
|
||||
unsigned short counter = ZERO;
|
||||
unsigned short counter_max = ZERO;
|
||||
while(vec[place])
|
||||
{
|
||||
counter = (vec[place] == vec[place + ONE]) ? ++counter : ZERO;
|
||||
counter_max = (counter_max > counter) ? counter : counter_max;
|
||||
}
|
||||
|
||||
return counter_max + 1;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------
|
||||
// Exercise 4
|
||||
// ----------
|
||||
//
|
||||
// General : The program checks how many substring can u build with the string that you
|
||||
// get in the main string you got.
|
||||
//
|
||||
// Input : string.
|
||||
//
|
||||
// Process : The program checks if there is a char like the start (char start) that the
|
||||
// program got, if there is it will check how many ends (char end) and just
|
||||
// add it too the counter.
|
||||
//
|
||||
// Output : How many substring can you build.
|
||||
//
|
||||
//---------------------------------------------------------------------------------------
|
||||
// Programmer : Cohen Idan
|
||||
// Student No : 211675038
|
||||
// Date : 04.11.2019
|
||||
//---------------------------------------------------------------------------------------
|
||||
void main(void)
|
||||
{
|
||||
typedef char string[STRING_MAX_SIZE];
|
||||
string str_arr[TEN];
|
||||
|
||||
unsigned short counter;
|
||||
unsigned short max;
|
||||
unsigned short max_offset;
|
||||
|
||||
for(counter = ZERO; counter < TEN; counter++)
|
||||
{
|
||||
scanf("%s", str_arr[counter]);
|
||||
}
|
||||
|
||||
max = HighestSequence(str_arr[ZERO]);
|
||||
max_offset = ZERO;
|
||||
for (counter = ONE; counter < TEN; counter++)
|
||||
{
|
||||
if(max < HighestSequence(str_arr[counter]))
|
||||
{
|
||||
max = HighestSequence(str_arr[counter]);
|
||||
max_offset = counter;
|
||||
}
|
||||
}
|
||||
printf("%s %hu\n",str_arr[max_offset], max_offset + ONE);
|
||||
|
||||
scanf("%hu",&counter);
|
||||
}
|
||||
13
9/test.c
Normal file
13
9/test.c
Normal file
@@ -0,0 +1,13 @@
|
||||
#include <stdio.h>
|
||||
#include "IdanStringLib.h"
|
||||
|
||||
void main(void)
|
||||
{
|
||||
char str1[100] = {'a', 'b', 'c', 'b', 'e', '\0'};
|
||||
char str2[100] = {'b', '\0'};
|
||||
|
||||
RemoveAllStringBFromStringA(str1, str2);
|
||||
printf("%u\n", StringLenght(str1));
|
||||
printf("%s\n", str1);
|
||||
printf("%d\n", !0);
|
||||
}
|
||||
Reference in New Issue
Block a user