ParanoidPanda

Untitled

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