Advertisement
NAHID_GTC

Untitled

Feb 1st, 2018
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. int main()
  4. {
  5. char s[1002], word[100];
  6. int i, j, length, I_W_S;
  7. gets(s);
  8. length = strlen(s);
  9. I_W_S = 0;
  10.  
  11. for(i = 0, j = 0; i < length; i++) {
  12. if(s[i] >= 'a' && s[i] <= 'z') {
  13. if(I_W_S == 0) {
  14. I_W_S = 1;
  15. word[j] = 'A' + s[i] - 'a';
  16. j++;
  17. }
  18. else {
  19. word[j] = s[i];
  20. j++;
  21. }
  22. }
  23. else if(s[i] >= 'A' && s[i] <= 'Z' || s[i] >= '0' && s[i] <= '9') {
  24. if(I_W_S == 0) {
  25. I_W_S = 1;
  26. }
  27. word[j] = s[i];
  28. j++;
  29. }
  30. else {
  31. if(I_W_S == 1) {
  32. I_W_S = 0;
  33. word[j] = '\0';
  34. printf("%s\n", word);
  35. j = 0;
  36. }
  37. }
  38. }
  39. return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement