Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as C by LongestPhrase ( 6 years ago )
#include <stdio.h>
#include <conio.h>
#include <string.h>
void longestPhrase(char *s)
{
int length = strlen(s), count = 0, Max = 0;
char phrase[10], newPhrase[10], n = 0, m = 0;
for(int i = 0; i < length; i++)
{
if(s[i] != ' ')
{
count++;
phrase[n++] = s[i];
//printf("%s", phrase[i]);
}
if(s[i] == ' ')
{
if(Max < count)
{
Max = count;
newPhrase[m] = phrase[n];
//newPhrase[i] = phrase[i];
}
n = 0;
count = 0;
}
}
newPhrase[m] = '\0';
printf("Max = %d", Max);
printf("\nphrase = %s", newPhrase);
}
int main()
{
char s[] = "Nguyen Huy Hellooooo";
longestPhrase(s);
}
Revise this Paste
Children: 105442