Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- string insert(string str1 , string str2);
- int main()
- {
- string str1 = "8" ,str2 = "13";
- int n = str2.length() - str1.length();
- str1.insert(0, n, '0');
- cout << str1 << endl ;
- return 0 ;
- }
- /*Phương thức insert( ) chèn thêm ký tự hay chuỗi vào một vị trí nào đó của chuỗi str cho trước. Có nhiều cách
- dùng phương thức này:
- str.insert(int pos, char* s); chèn s (mảng ký tự kết thúc ‘\0’) vào vị trí pos của str;
- str.insert(int pos, string s); chèn chuỗi s (kiểu string) vào vị trí pos của chuỗi str;
- str.insert(int pos, int n, int ch); chèn n lần ký tự ch vào vị trí pos của chuỗi str;
- */
Advertisement
Add Comment
Please, Sign In to add comment