First Upload
This commit is contained in:
58
10/ex2.c
Normal file
58
10/ex2.c
Normal file
@@ -0,0 +1,58 @@
|
||||
#include <stdio.h>
|
||||
#include "IdanStringPointersLib.h"
|
||||
|
||||
#define STRING_MAX_SIZE 256
|
||||
|
||||
//---------------------------------------------------------------------------------------
|
||||
// MaxCountCharInString
|
||||
// --------------------
|
||||
//
|
||||
// General : Checks which character is most often in the string.
|
||||
//
|
||||
// Parameters :
|
||||
// *start_string_index - Pointer of string (char[])
|
||||
//
|
||||
// Return value : The number of times the character appears most often (unsigned int).
|
||||
//
|
||||
//---------------------------------------------------------------------------------------
|
||||
// Programmer : Cohen Idan
|
||||
// Student No : 211675038
|
||||
// Date : 12.11.19
|
||||
//---------------------------------------------------------------------------------------
|
||||
unsigned int MaxCountCharInString(char *start_string_index)
|
||||
{
|
||||
unsigned int max = ZERO,
|
||||
count_temp;
|
||||
while (*start_string_index)
|
||||
{
|
||||
count_temp = CountCharInString(start_string_index++, *start_string_index);
|
||||
max = (count_temp > max) ? count_temp : max;
|
||||
}
|
||||
|
||||
return (max);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
// exe 2
|
||||
// -----
|
||||
// General : the program checks which char repeats itself the most
|
||||
// in a string and shows how many times it shows up.
|
||||
//
|
||||
// Input : a string.
|
||||
//
|
||||
// Process : goes over every letter and checks the amount of it.
|
||||
//
|
||||
// Output : the highest repeating char and the times it appeared
|
||||
// in string.
|
||||
//
|
||||
//-----------------------------------------------------------------
|
||||
// Proggramer : Cohen Idan
|
||||
// Student No : 211675038
|
||||
// Date : 12.11.19
|
||||
//-----------------------------------------------------------------
|
||||
void main(void)
|
||||
{
|
||||
char stringA[STRING_MAX_SIZE] = "aaaaaaaaaaaaababbbbbbbbbabbbbbbbb";
|
||||
printf("Count: %u\n", MaxCountCharInString(&stringA[ZERO]));
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user