Closed ErSKS closed 7 years ago
package pattern26;
/*
@author Kiran */ public class Pattern26 {
/**
@param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here String s = "123456789"; final int N=5; for (int i = 0; i < N; i++) {
for (int j = 0; j <N-i ; j++)
System.out.print(" ");
for(int j=i; j<=2*i;j++)
System.out.print(s.charAt(j));
for(int j=2*i-1; j>=i;j--)
System.out.print(s.charAt(j));
System.out.println("");
}
}
}
Output:
package patternmore3;
import static java.lang.Integer.parseInt;
/*
@author Jagdish Duwal */ public class PatternMore3 {
/**
@param args the command line arguments */ public static void main(String[] args) { String s = "123456789"; int i, j,odd =0,k=0,l; for(i = 0 ; i< s.length(); i++){ String a = s.substring(i,i+1); odd = (parseInt(a)%2==1) ? ++odd: odd; }
for(i = 0 ; i<odd; i++){
for(j = s.length()-odd ; j>i ; j--){
System.out.print(" ");
}
System.out.print(s.substring(k,k+(k+1)));
l=k+(k+1);
for(j = 0 ; j<i ; j++){
System.out.print(s.charAt(l-2));
l--;
}
k++;
System.out.println("");
}
}
}
package pattern25;
import java.util.Scanner;
/*
@author m-lan */ public class Pattern25 {
/**
}
/*
/*
@author Anish */ public class Pattern25 {
/**
}
/*
import java.util.Scanner;
/*
@author Dragon15423 */ public class Day10Patterns {
/**
@param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here Scanner input = new Scanner(System.in); System.out.println("Enter the length of pattern: "); int in = input.nextInt();
for (int i = 1; i <= in; i++) {
for (int j = in; j > i; j--) {
System.out.print(" ");
}
for (int j = 0; j < i; j++) {
System.out.print(i + j + " ");
}
for (int j = i; j > 1; j--) {
System.out.print(i + j - 2 + " ");
}
System.out.println("");
}
}
}
/*
/*
@author DELL */ public class Pattern25 {
/**
OUTPUT
/*
/*
@author kajal */ public class Pattern25 {
/**
@param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here int n, a; for (int i = 1; i <= 5; i++) { for (int j = 1; j <= 5 - i; j++) {
System.out.printf(" ");
}
for (int j = 1; j <= i; j++) {
n = i + j - 1;
System.out.printf("%d", n);
}
for (int j = i; j > 1; j--) {
a = i + j - 2;
System.out.printf("%d", a);
}
System.out.println(" ");
}
}
}
/*
/*
@author dell */ public class Pattern24 {
public static void main(String[] args) {
for (int i = 1; i <= 5; i++) {
for (int j = 1; j <= 5 - i; j++) {
System.out.print(" ");
}
for (int k = 1; k <= i; k++) {
System.out.print(i + k - 1);
}
for (int j = i; j > 1; j--) {
System.out.print(i + j - 2);
}
System.out.println();
}
} }
/*
/*
@author nissus */ public class P25 {
/**
for (int i = 1; i <= 5; i++) { for (int j = 1; j <= 5 - i; j++) { System.out.print(" "); } for (int k = 1; k <= i; k++) {System.out.print(i + k - 1);
}
for (int j = i; j > 1; j--) { System.out.print(i + j - 2); } System.out.println(); } } }
public static void main(String[] args) { // TODO code application logic here String s = "123456789"; final int N = 5; for (int i = 0; i < N; i++) {
for (int j = 0; j < N - i; j++) {
System.out.print(" ");
}
for (int j = i; j <= 2 * i; j++) {
System.out.print(s.charAt(j));
}
for (int j = 2 * i - 1; j >= i; j--) {
System.out.print(s.charAt(j));
}
System.out.println("");
}
}
/*
/*
@author LORDsajan */ public class Patt33 {
/**
}
package day09pattern25;
/*
@author Samikshya */ public class Day09Pattern25 {
/**
@param args the command line arguments */ public static void main(String[] args) { for (int i = 1; i <= 5; i++) { for (int j = 1; j <= 5 - i; j++) { System.out.print(" "); } for (int k = 1; k <= i; k++) { System.out.print(i + k - 1);
}
for (int j = i; j > 1; j--) {
System.out.print(i + j - 2);
}
System.out.println();
} }
}
package day9pattern25;
import static java.lang.Integer.parseInt; import javax.swing.JOptionPane;
/*
@author DELL */ public class Day9pattern25 {
/**
@param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here int n = parseInt(JOptionPane.showInputDialog("Enter the number of rows")); for (int i = 1; i <= n; i++) { for (int j = 1; j <= n - i; j++) { System.out.print(" "); }
for (int k = 1; k <= i; k++) {
System.out.print(i + k - 1);
}
for (int j = i; j > 1; j--) {
System.out.print(i + j - 2);
}
System.out.println("");
} } }
/*
import java.util.Scanner;
/*
@author admin */ public class Pattern25 {
/**
@param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here Scanner input = new Scanner(System.in); System.out.println("Enter a number"); int n = input.nextInt();
for (int i = 1; i <= n; i++) { for (int j = 1; j <= n - i; j++) { System.out.print(" "); }
for (int k = 1; k <= i; k++) {
System.out.print(i + k - 1);
}
for (int j = i; j > 1; j--) {
System.out.print(i + j - 2);
}
System.out.println("");
} } }
package patterntwentyfive;
/*
@author User */ public class PatternTwentyFive {
/**
@param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here
for (int i = 1; i <= 5; i++) { for (int j = 5; j > i; j--) { System.out.print(" "); } for (int j = 0; j < i; j++) { System.out.print(i + j + " "); } for (int j = i; j > 1; j--) { System.out.print(i + j - 2 + " "); } System.out.println(" "); } } }
public static void main(String[] args) {
for (int i = 1; i <= 5; i++) {
for (int j = 1; j <= 5 - i; j++) {
System.out.print(" ");
}
for (int k = 1; k <= i; k++) {
System.out.print(i + k - 1);
}
for (int j = i; j > 1; j--) {
System.out.print(i + j - 2);
}
System.out.println("");
}
}
public static void main(String[] args) { // TODO code application logic here for (int i = 1; i <= 5; i++) {
for (int j = 1; j <= 5 - i; j++) {
System.out.print(" ");
}
for (int k = 1; k <= i; k++) {
System.out.print(i + k - 1);
}
for (int j = i; j > 1; j--) {
System.out.print(i + j - 2);
}
System.out.println("");
}
}
}
CODE: package pattern25;
/*
@author User */ public class Pattern25 {
/**
@param args the command line arguments */ public static void main(String[] args) {
for (int i = 1; i <= 5; i++) {
for (int j = 1; j <= 5 - i; j++) {
System.out.print(" ");
}
for (int k = 1; k <= i; k++) { System.out.print(i + k - 1); } for (int j = i; j > 1; j--) { System.out.print(i + j - 2); } System.out.println(""); } } } Output:
public static void main(String[] args) { String s = "123456789"; final int N = 5; for (int i = 0; i < N; i++) {
for (int j = 0; j < N - i; j++) {
System.out.print(" ");
}
for (int j = i; j <= 2 * i; j++) {
System.out.print(s.charAt(j));
}
for (int j = 2 * i - 1; j >= i; j--) {
System.out.print(s.charAt(j));
}
System.out.println("");
}
}
}
// TODO code application logic here }
}
/*
/*
@author Lenovo */ public class PatternNo25 {
/**
@param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here
for (int i = 0; i <= 5; i++) { for (int j = 1; j <= 5 - i; j++) { System.out.print(" "); } for (int j = 1; j <= i; j++) { System.out.print(i + j - 1 + ""); } for (int j = i; j > 1; j--) { System.out.printf(i + j - 2 + ""); } System.out.println(" "); } } }
Given String s = "123456789"