C
#include <stdio.h> int isVowel(const char letter); int highestConsonantSubstring(const char* string); int main(void) { printf("%d\n", highestConsonantSubstring("strength")); printf("%d\n", highestConsonantSubstring("chruschtschov")); return 0; } int isVowel(const char letter) { switch (letter) { case 'a': case 'e': case 'i': case 'o': case 'u': return 1; default: return 0; } } int highestConsonantSubstring(const char* string) { const char* letter = string; unsigned int highest = 0; unsigned int current = 0; for (const char* letter = string; *letter; letter++) { if (!isVowel(*letter)) { current += *letter - 96; continue; } if (highest < current) { highest = current; } current = 0; } return highest; }
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
C