Xóa Khoảng Trắng Thừa Trong Chuổi

///===== Không Sử Dụng Thư Viện Nào Hổ Trợ Đó Nha kkkk ^_^ #include<iostream> using namespace std; int diem(char *s,int d=0) { while(s[d++]!=0); return d-1; } void xoa(char *s,int position) { int lenth=diem(s); for(int i=position;i<lenth;i++) { s[i]=s[i+1]; } s[lenth-1]='\0'; } void Xoakhoangtrangthua(char *s) { int lenth=diem(s); for(int i=0;i<lenth;i++) { if(s[i]==' '&&s[i+1]==' ') { xoa(s,i); i--; } } } int main() { char s[]="anh chuc cute"; Xoakhoangtrangthua(s); cout<<s; system("pause"); return 0; }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.