public class testCase1{
public static void main(String[] args) {
/* ***********Pattern Printing*********** */
/*
int k = 1;
for (int i = 1; i <= 4; i++) {
for (int j = 1; j <= i; j++) {
System.out.printf("%d", k);
k++;
}
System.out.println();
k--;
}}}
1
12
234
4567
*/
public class testCase1{
public static void main(String[] args) {
for (int i = 0; i <= 5; i++) {
for (int j = 1; j <= 5-i; j++) {
System.out.print(" ");
}
for (int k = 0; k <= i*2; k++) {
System.out.print("#");
}
System.out.println();
}}}
#
###
#####
#######
#########
###########
/*
public class testCase1{
public static void main(String[] args) {
for (int i = 0; i <= 5; i++){
for(int j = 0; j <= i; j++){
System.out.print(" ");
}
for(int k = 0; k <= 5-i; k++){
System.out.print("#");
}
System.out.println();
}}}
######
#####
####
###
##
#
*/
/*
public class testCase1{
public static void main(String[] args) {
for(int i = 0; i <= 5; i++){
for(int j = 0; j <= i; j++){
System.out.print(" ");
}
for(int k = 0; k <= 2*(5-i); k++){
System.out.print("#");
}
System.out.println();
}}}
###########
#########
#######
#####
###
#
*/
/*
public class testCase1{
public static void main(String[] args) {
for (int i = 0; i <= 5; i++) {
for (int j = 0; j <= 5-i; j++) {
System.out.print(" ");
}
for (int k = 0; k <= i*2; k++) {
System.out.print("#");
}
System.out.println();
}
for(int i = 0; i <= 4; i++){
for(int j = 0; j <= i; j++){
System.out.print(" ");
}
for(int k = 0; k <= 2*(4-i); k++){
if( k == 0) System.out.print(" ");
System.out.print("#");
}
System.out.println();
}}}
#
###
#####
#######
#########
###########
#########
#######
#####
###
#
*/
/*
public class testCase1{
public static void main(String[] args) {
for(int i = 1; i <= 5; i++){
for(int j = 1; j <= i; j++){
System.out.print(j);
}
System.out.println();
}}}
1
12
123
1234
12345
*/
/*
public class testCase1{
public static void main(String[] args) {
for(int i = 1; i <= 5; i++){
for(int j = 1; j <= i; j++){
System.out.print(" ");
}
for(int k = 1; k <= 5-i+1; k++){
System.out.print(k);
}
System.out.println();
}}}
12345
1234
123
12
1
*/
/*
public class testCase1{
public static void main(String[] args) {
int s = 1,temp = 1;
for(int i = 1; i <= 5; i++){
for(int k = 1; k <= 5-i; k++){
System.out.print(" ");
}
for(int k = 1; k <= i; k++){
System.out.print(temp);
temp--;
}
s++;
temp = s;
System.out.println();
}}}
1
21
321
4321
54321
*/
/*
public class testCase1{
public static void main(String[] args) {
int a = 8;
for(int i = 1; i <= 8; i++){
for(int j = a; j >= 1; j--){
System.out.print(j);
}
a--;
System.out.println();
}}}
87654321
7654321
654321
54321
4321
321
21
1
*/
/*
public class testCase1{
public static void main(String[] args) {
int s = 1, a = 1;
for(int i = 1; i <= 8; i++){
for(int j = 8; j >= i; j--){
System.out.print(" ");
}
for(int k = 1; k <= i; k++){
System.out.print(k);
}
for(int l = 1; l <= i-1; l++){
System.out.print(s);
s--;
}
s = a;
a++;
System.out.println();
}}}
1
121
12321
1234321
123454321
12345654321
1234567654321
123456787654321
*/
/*
public class testCase1{
public static void main(String[] args) {
int x = 7, a = 6;
for(int i = 1; i <= 8; i++){
int s= 1;
for(int j = 1; j <= i; j++){
System.out.print(" ");
}
for(int k = 1; k <= 8-i+1; k++){
System.out.print(s);
s++;
}
for(int l= 1; l <= 8-i; l++){
System.out.print(x);
x--;
}
x = a;
a--;
System.out.println();
}}}
123456787654321
1234567654321
12345654321
123454321
1234321
12321
121
1
*/
/*
public class testCase1{
public static void main(String[] args) {
int y = 1, z = 1;
for(int i = 1; i <= 8; i++){
for(int j = 1; j <= i; j++){
System.out.print(j);
}
for(int k = 1; k <= 8-i-1; k++){
System.out.print(" ");
}
for(int l= 1; l <= 8-i; l++){
System.out.print(" ");
}
for(int m = 1; m <= i; m++){
if(y > 0)
System.out.print(y);
y--;
}
if(z < 7)
z++;
y = z;
System.out.println();
}}}
1 1
12 21
123 321
1234 4321
12345 54321
123456 654321
1234567 7654321
123456787654321
*/
/* find max number in array */
/*
import java.util.Scanner;
public class testCase1
{
public static void main(String[] args)
{
int n, max;
Scanner s = new Scanner(System.in);
System.out.print("Enter number of elements in the array:");
n = s.nextInt();
int a[] = new int[n];
System.out.println("Enter elements of array:");
for(int i = 0; i < n; i++)
{
a[i] = s.nextInt();
}
max = a[0];
for(int i = 0; i < n; i++)
{
if(max < a[i])
{
max = a[i];
}
}
System.out.println("Maximum value:"+max);
}
}
Enter number of elements in the array:10
Enter elements of array:
2
5
7
8
3
5
7
10
15
9
Maximum value:15
*/
/* Selection Sorting */
/*
import java.util.Scanner;
public class testCase1
{
public static void main(String[] args)
{
int n,temp;
Scanner s = new Scanner(System.in);
System.out.print("Enter number of elements in the array:");
n = s.nextInt();
int a[] = new int[n];
System.out.println("Enter elements of array:");
for(int i = 0; i < n; i++)
{
a[i] = s.nextInt();
}
for(int i = 0; i < n-1; i++)
{
for(int j = 0; j < n-i-1; j++){
if(a[j] <= a[j+1]){
temp = a[j];
a[j] = a[j+1];
a[j+1] = temp;
}
}
}
for(int i = 0; i < n; i++){
System.out.print(a[i]);
}
}
}
Enter number of elements in the array:8
Enter elements of array:
2
5
9
3
1
0
6
8
98653210om@om:~/Documents$
*/
Give Something to the world and it will never let you down.
Onkar Dubey
No comments:
Post a Comment