Lisaveta777

супер легкая

Dec 3rd, 2019
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.60 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <ctype.h>
  3. #define SIZE 20
  4.  
  5.  
  6. int main()
  7. {
  8.     int i,j,inword = 0;
  9.     char str[SIZE]="abc def ghk lmn opq";
  10.  
  11.  
  12.     for(i=0;i<SIZE;i++)
  13.     {
  14.         if(!inword&&isalpha(str[i]))//first letter in word
  15.             {
  16.                 str[i] = toupper(str[i]);
  17.                 inword=1;
  18.             }
  19.         else if(inword&&!(isalpha(str[i])))//first non-alpha after word
  20.             {
  21.                 str[i-1] = toupper(str[i-1]);
  22.                 inword=0;
  23.             }
  24.  
  25.     }
  26.  
  27.     for(i=0;i<SIZE;i++)
  28.         printf("%c  ",(str[i]));
  29.  
  30.  
  31.     return 0;
  32. }
Add Comment
Please, Sign In to add comment