Print All Substrings
For a given input string(str), write a function to print all the possible substrings.
Substring
Input Format:
Output Format:
Note:
Constraints:
Sample Input 1:
Sample Output 1:
Sample Input 2:
Sample Output 2:
#include <iostream>
#include <cstring>
using namespace std;
#include "solution.h"
#include<cstring>
void printSubstrings(char input[]) {
for(int l=0;input[l]!='\0';l++){
for(int i=l;input[i]!='\0';i++){
for(int j=l;j<=i;j++){
cout<<input[j];
}
cout<<endl;
}
}
}
int main() {
int size = 1e6;
char str[size];
cin >> str;
printSubstrings(str);
}
Comments
Post a Comment