Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <locale>
- int mystrlen(char *string);
- int main(){
- //char string[] = "swallow up - If a person or thing is swallowed up by something, they disappear into it so that you cannot see them any more.";
- char string[1024];
- gets(string);
- char min_word[15];
- int step = 0;
- int word_begin = 0, word_end = 0, word_min = 15;
- for (int i = 0; i < strlen(string); i++){
- if (string[i] >= 'a' && string[i] <= 'z'){
- if (i > 0){
- if (string[i - 1] < 'a'){
- word_begin = i;
- }
- }
- else{
- word_begin = i;
- }
- }
- if (string[i] < 'a'){
- word_end = i - 1;
- }
- if (word_end > word_begin && word_end - word_begin <= word_min){
- word_min = word_end - word_begin;
- for (int it = 0; it < 15; it++){
- min_word[it] = ' ';
- }
- step = 0;
- for (int is = word_begin; is <= word_end; is++){
- min_word[step] = string[is];
- step++;
- }
- }
- }
- for (int it = 0; it < 15; it++){
- if (min_word[it] >= 'a' && min_word[it] <= 'z')
- printf("%c", min_word[it]);
- }
- printf("\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment