Advertisement
FlyFar

C++ Lab

Oct 25th, 2021
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4. string StrDel(string, int, int);
  5.  
  6. int main() {
  7.     string str1 = "ingSSSRing";
  8.  
  9.     cout << StrDel(str1, 3, 7);
  10. }
  11.  
  12. string StrDel(string s, int n, int k) {
  13.     string start = s.substr(0, n);
  14.     string end = s.substr(k);
  15.     return start + end;
  16. }
  17.  
  18. public class Main
  19. {
  20.   public static void main (String[]args)
  21.   {
  22.     String s = "ingSSSRing";
  23.     System.out.println(StrDel(s, 3, 7));
  24.   }
  25.  
  26.   public static String StrDel (String s, int n, int k)
  27.   {
  28.     String start = s.substring (0, n);
  29.     String end = s.substring (k);
  30.  
  31.     return start + end;
  32.   }
  33. }
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement