Skip to content

Instantly share code, notes, and snippets.

@gotoark
Created December 24, 2016 04:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gotoark/90fe4d3c1409df1756254e76223d7cbe to your computer and use it in GitHub Desktop.
Save gotoark/90fe4d3c1409df1756254e76223d7cbe to your computer and use it in GitHub Desktop.
String Pattern
import java.util.Scanner;
public class StringCombination {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scan= new Scanner(System.in);
String name=new String();
name=scan.next();
int iterations=0,n,s,e;
e=1; //Initialize word count
for(int i=name.length();i>=0;i--){
n=i;
s=0;
while(n>0){
System.out.println(name.substring(s,s+e));
s++;
n--;
}
e++;
//end of for
}
}
}
@gotoark
Copy link
Author

gotoark commented Dec 24, 2016

Input: GITHUB
OUTPUT:
G
I
T
H
U
B
GI
IT
TH
HU
UB
GIT
ITH
THU
HUB
GITH
ITHU
THUB
GITHU
ITHUB
GITHUB

@shangeethsivan
Copy link

Sooper ji

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment