helsinki2103

UIT 8.03

Dec 29th, 2020
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. void Chuanhoa(char s[])
  2. {
  3.     int f = 0;
  4.     char cur[MAX];
  5.     int j = 0;
  6.     for (int i=0; i<MAX; i++)
  7.     {
  8.         if (s[i]==' ')
  9.         {
  10.             if (f)
  11.             {
  12.                 f = 0;
  13.                 cur[j] = ' ';
  14.                 ++j;
  15.             }
  16.         }
  17.         else
  18.         {
  19.             if (f==0)
  20.             {
  21.                 cur[j] = toupper(s[i]);
  22.                 j++;
  23.                 f = 2;
  24.             }
  25.             else if (f==2)
  26.             {
  27.                 cur[j] = tolower(s[i]);
  28.                 ++j;
  29.             }
  30.         }
  31.     }
  32.     for (int i=0; i<300; i++) s[i] = cur[i];
  33. }
Advertisement
Add Comment
Please, Sign In to add comment