ParanoidPanda

Untitled

Nov 12th, 2015
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <locale>
  4.  
  5. int mystrlen(char *string);
  6.  
  7. int main(){
  8. 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.";
  9. char min_word[15];
  10. int step = 0;
  11. int word_begin = 0, word_end = 0, word_min = 15;
  12. for (int i = 0; i < strlen(string); i++){
  13. if (string[i] >= 'a' && string[i] <= 'z'){
  14. if (i > 0){
  15. if (string[i - 1] < 'a'){
  16. word_begin = i;
  17. }
  18. }
  19. else{
  20. word_begin = i;
  21. }
  22. }
  23. if (string[i] < 'a'){
  24. word_end = i - 1;
  25. }
  26. if (word_end > word_begin && word_end - word_begin <= word_min){
  27. word_min = word_end - word_begin;
  28. for (int it = 0; it < 15; it++){
  29. min_word[it] = ' ';
  30. }
  31. step = 0;
  32. for (int is = word_begin; is <= word_end; is++){
  33. min_word[step] = string[is];
  34. step++;
  35. }
  36. }
  37. }
  38. for (int it = 0; it < 15; it++){
  39. if (min_word[it] >= 'a' && min_word[it] <= 'z')
  40. printf("%c", min_word[it]);
  41. }
  42. printf("\n");
  43. return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment