Good afternoon)) For the second day I’m trying to write this program, but I don’t get anything (((Help please. There is a condition that finds the longest word in the sentence. Now you need to delete words that consist of Latin letters. (You cannot use string and so on)
int main(int argc, char** argv) { setlocale(LC_ALL, "Russian"); char str[80]; cout << "Enter string: "; cin.getline(str,80); int i; //Выводим само длинно слово int lenght = strlen(str); int maxLen = 0; int index = 0; int count = 0; for (i = 0; i < lenght; i++) { if (str[i] != ' '){ count += 1; } else { if (count > maxLen) { maxLen = count; index = i - count; } count = 0; } } if (count > maxLen) { maxLen = count; index = i - count; } maxLen += index; printf("\n"); for (i = index; i < maxLen; i++){ //putchar(str[i]); cout << str[i]; } printf("\n"); bracket(str); So I tried to write something (n-time), but as always it does not work)
int temp =0; for(int i=0; i < lenght; i++){ if (((str[i]>='a')&&(str[i]<='z'))||((str[i]>='A')&&(str[i]<='Z'))){ temp++; } else str[i-temp] = str[i]; lenght-=temp; } cout << lenght; for(int i=0;i<lenght;i++) cout << str[i]; return 0; }