////// chuoi ben c++ m.....................
#include<iostream>
using namespace std;
#include<string>
#include<string.h>
#include<algorithm>// thu vien that toan
// thang tring con ket hop voi thang <algorithm> ham nay de chay nhung chuong trinh rat la nhanh
int main()
{
/* nhap chuoi
string s;
cout<<"moi ban nhap vao chuoi ";
getline(cin,s);
// cin la nhap tu ban phiem
// s la n2 luu vào s
cout<<"chuoi vua nhap la "<<s;
noi chuoi
/*string a=" chuc ", b="dep";
a+=b;
cout<<a;
so sanh 2 chuoi
so sanh nay dua tren algorithm
if(a==b)
{
//chuoi a == chuoi b
}
else if(a>b)
{
// chuoi a lon hon chuoi b
}
else
{
// chuoi a nho hon chuoi b
}
*/
// gan chuoi nay cho chuoi kia
//o ben c: ko lam duoc dieu nay
//char s[30];
//s="yeu anh ko hahahaha";
// nhung ben c++
/*string s1;
s1="yeu anh ko hahahhaha";
//hoan toan hop le
cout<<s1;
*/
// dao nguoc chuoi
/*string s1;
s1="chuc gia nhat";
strrev((char *)s1.c_str());
cout<<s1;
*/
// chu thuong chu hoa
/*string s1;
s1="chuc gia nhat";
strlwr((char *)s1.c_str());
cout<<s1;
strupr((char *)s1.c_str());
cout<<"\n"<<s1;
int c=strlen((char *)s1.c_str());
cout<<c;
*/
// ham cat chuoi con 0123456
// 01234567891111111
string s1="anh chuc dep trai ";
string s4=s1.substr(9,4);
cout<<"\n"<<s4;
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.