Write a C++ program to insert a given string into middle of the another given string of length 4

  • برمجة سي بلس بلس
  • برمجة

Write a C++ program to insert a given string into middle of the another given string of length 4

Sample Output:

[[Hello]]
((Hi))

الأجوبة

#include <iostream>

using namespace std;

string test(string s1, string word)
         {
            return s1.substr(0, 2) + word + s1.substr(2);
         }         
       
int main() 
 {
  cout << test("[[]]","Hello") << endl;  
  cout << test("(())", "Hi") << endl;  
  return 0;    
}
هل كان المحتوى مفيد؟

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...