# Problem 5

### 11 comments on “Problem 5”

• Pogakula

#python3
def subse(s):
for i in range(1,len(s)+1):
for j in range(0,len(s)-i+1,1):
print(s[j:i+j],end=’ ‘)
stri=str(input(‘enter the string:\t’))
subse(stri)

• swapnil

public class substring {
public static void main(String[] args) {
boolean flag=true;
Scanner s=new Scanner(System.in);
String s1=s.nextLine();
char[] arrs=s1.toCharArray();
for(int i =0;i<arrs.length;i++) {
for(int j=0;j<arrs.length;j++) {
flag=true;
for(int k =i;k<=j;k++) {
System.out.print(arrs[k]);
flag=false;
}
if(flag==false) {
System.out.println("");}
}
}
}
}

• swapnil

public class className {

public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc= new Scanner(System.in);
String s=sc.nextLine();
String[] s1=s.split(“”);
int k=0;
for(String i:s1) {
k=k+1;
for(int j=k;j<s1.length;j++) {
System.out.println(s.substring(s.indexOf(i),j));
}
}

}

}

• swapnil

s=[str(i) for i in input()]
for k in range(len(s)+1):
for l in range(k+1,len(s)+1):
print(”.join(str(j) for j in s[k:l]))

• The Bong

import java.util.ArrayList;

public class SubStringProblem {
public static void main(String[] args) {
String s = “String”;
printAllSubstring(s);
}
static void printAllSubstring(String s) {
ArrayList aList = new ArrayList();
for (int i = 0; i < s.length(); i++) {
for (int j = i+1; j <= s.length(); j++) {
}
}
for(String str: aList) {
System.out.print(str+" ");
}
}
}

• SK.ISHAN

#include
using namespace std;
void is(string a,int n){
for(int i=0;i<n;i++){
for(int j=i;j<n;j++){
for (int k=i;k<=j;k++)
cout<<a[k]<<" ";
cout <>s;
is(s,s.size());
}

• subhojit

from itertools import combinations
s=input()
l=list(s)
l2=list()
sub=list()
for i in range(1,len(l)+1,1):
sub=list(combinations(l,i))
l2.append(sub)
for i in range(0,len(l2),1):
for j in range(0,len(l2[i])):
print(*l2[i][j],end=” , “)
print()

• kandukuri

#include
#include
void main()
{
char str[] = “abcd”;
int length = strlen(str);
for (int i = 0; i < length; i++) /// to print total length of the string
{
for (int j = 0; j < length – i; j++) ///decreasing the length
{
for (int k = i; k < length – j; k++) // printing the value from where we started str[i] value.. to total string based on the length decided by j
{
printf("%c", str[k]);
}
printf("\n");
}
}
}

• Srimukhi

IN C
#include
int main()
{
int i,j,l,k,r;
char s1[100],s2[100],s3[100];
scanf(“%[^\n]%*c”,s1);
scanf(“%[^\n]%*c”,s2);
scanf(“%[^\n]%*c”,s3);

for(l=0;s2[l]!=’\0′;l++);
for(i=0,j=0;s1[i]!=’\0′,s2[j]!=’\0′;i++)
{
if(s1[i]==s2[j])
j++;
else
j=0;
}
if(j==l){
for(r=0,k=i-j;s3[r]!=’\0′;r++,k++)
s1[k]=s3[r];
}
else