zyn468
BAN USERpublic class ProgressiveDigits {
public static void main(String[] args){
int n = 4;
int digit = 0;
int lower_bound = (int) Math.pow(10, n-1);
int upper_bound = (int) Math.pow(10, n);
for(int result = lower_bound; result < upper_bound; result++){
if(checkProgress(n, result, digit)){
System.out.println(result);
}
}
}
static boolean checkProgress(int n, int result, int digit){
while(digit < n ){
if((result/(int) Math.pow(10, digit))%10 > (result/(int) Math.pow(10, digit+1))%10){
digit++;
}else{
return false;
}
}
return true;
}
}
public class PalindromeInString {
public static void main(String[] args){
String orginal = "bccbaabcedtdecb";
FindPld(orginal);
}
static void FindPld(String s){
char[] cha = s.toCharArray();
for(int i= 2; i <s.length()-3; i++){
if(cha[i] == cha[i+1]){
int size = 1;
if(i<s.length()/2+1){
for(int j= 1; j<i+1; j++){
if(cha[i-j] == cha[i+1+j]){
size++;
}
}
}else{
for(int j= 1; j<s.length()-i-1; j++){
if(cha[i-j] == cha[i+1+j]){
size++;
}
}
}
if(size >2 && size<s.length()){
System.out.println(s.substring(i-size+1, i+size+1));
}
}
}
}
}
print while reading or after stop?
- zyn468 April 14, 2014