spider68

substring

Mar 12th, 2020
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. void subString(string s, int n)
  4. {
  5. for (int i = 0; i < n; i++)
  6. for (int len = 1; len <= n - i; len++)
  7. cout << s.substr(i, len) << endl;
  8. }
  9. int main()
  10. {
  11. string s = "abcd";
  12. subString(s,s.length());
  13. return 0;
  14. }
Add Comment
Please, Sign In to add comment