Code Chuyển Kí tự đầu tiên của mỗi từ thành hoa!
VD chao mung cac ban den voi trang web nhatcntt
>>> sẽ thành
Chao Mung Cac Ban Den Voi Trang Web Nhatcntt
VD chao mung cac ban den voi trang web nhatcntt
>>> sẽ thành
Chao Mung Cac Ban Den Voi Trang Web Nhatcntt
- Code:
#include <conio.h>
#include <stdio.h>
#include <string.h>
#include <iostream.h>
#include <ctype.h>
void nhapxau(char s[])
{
cout<<" Nhap vao xau : " ;
gets(s) ;
}
int xuly(char s[])
{ ;
for (int i=0 ; i< strlen(s) ; i++)
{ s[i]= toupper(s[i]);
if(i!=0 && s[i-1]!=' ')
s[i]= tolower(s[i]) ;
else
{
if(s[i+1]=='\0' && s[i]!=' ')
s[i]= tolower(s[i]) ;
}
}
cout<<" xau moi la: "<<s ;
}
void main()
{
char s[100] ;
nhapxau(s) ;
xuly(s) ;
getch() ;
}