Friday 27 July 2018

Character Pattern 8
Write a program to generate the following pattern.
*********
b******* b
bb***** bb
bbb***bbb
bbbb*bbbb


Input and Output Format:
Input consists of a single integer that corresponds to n, the number of rows. n is always an odd number.

Sample Input :
5

Sample Output :
*********
b******* b
bb***** bb
bbb***bbb
bbbb*bbbb
 
Solution:
  #include<stdio.h>
int main()
{
    int n,i,j;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        for(j=1;j<n*2;j++)
        {
            if(i>=j||j>=n*2-i)
            printf("b");
            else
            printf("*");
        }
        printf("\n");
    }
        return(0);
}

26 comments:

  1. // Considering n as a generalized input from the user.
    import java.util.*;
    public class Main {
    public static void main(String [] args){
    Scanner in = new Scanner(System.in);
    int n = in.nextInt();
    for(int i = n; i >= 1;i--) {
    for (int j = n;j > i ; j--) {
    System.out.print("b");
    }
    for (int k = 1; k <= i; k++) {
    System.out.print("*");
    }
    for (int l = 1; l<= i-1; l++) {
    System.out.print("*");
    }
    for(int m =n; m>i;m--) {
    System.out.print("b");
    }
    System.out.println();
    }
    }
    }

    ReplyDelete
    Replies
    1. The much awaited event at the entertainment industry every year is the "Screen Awards". This year the event is going to be organized on December 25 to honour the Artists for their professional excellence in Cinema. The Organizers of the event, J&R Events, decided to design some attractive and LED Matrix panel boards for the show promotions all across the venue.

      The Event organizers wanted to program the display boards with some specific pattern using alphabets and special characters. Help them write a program to design the pattern of a hollow pyramid in the matrix panel, given the number of lines of the pattern.

      Input Format:
      First line of the input is an integer that refers to the number of lines in the pattern.

      Output Format:
      Output the pattern as given in the output.
      Refer sample input and output for formatting specifications.

      Sample Input 1:
      4

      Sample Output 1:
      bbb*bbb
      bb*i*bb
      b*iii*b
      *******

      Delete
    2. #include
      using namespace std;
      int main()
      {
      int n,i,j,k;
      cin>>n;
      k=(2*n)-1;
      for(i=n;i>0;i--)
      {
      for(j=1;j<=k;j++)
      {
      if((j==i)||(j==k-i+1)||(i==1)){cout<<"*";}
      else if((jk-i)){cout<<"b";}
      else{cout<<"i";}
      }
      cout<<"\n";
      }
      return 0;
      }

      Delete
    3. int n = s.nextInt();
      int v=2*n-1;
      for(int i = n; i >= 1;i--) {
      for (int j = 1;j<=v ; j++) {
      if((j==i)||(j==v-i+1)||(i==1)){
      System.out.print("*");
      }
      else if( j>v-i+1 || j<i){
      System.out.print("b");
      }
      else{
      System.out.print("i");
      }
      }

      System.out.println();
      }

      Delete
    4. how many ques u have solved till now, mine java bt all ques are same, we can do it together

      Delete
  2. sir can you tell me the solution for this problem

    bbbb*bbbb
    bbb***bbb
    bb*****bb
    b*******b
    *********
    please tell the solution of this problem

    ReplyDelete
    Replies
    1. #include
      int main()
      {
      int n,i,j;
      scanf("%d",&n);
      for(i=n;i>=1;i--)
      {
      for(j=1;jj||j>n*2-i)
      printf("b");
      else
      printf("*");
      }
      printf("\n");
      }

      return 0;
      }

      Delete
  3. #include

    int main()
    {
    int n,i,j;
    scanf("%d",&n);
    for(i=n;i>=1;i--)
    {
    for(j=1;jj||j>n*2-i)
    printf("b");
    else
    printf("*");
    }
    printf("\n");
    }

    return 0;
    }

    ReplyDelete
  4. sir can u tell me the solution for the below
    bbb*bbb
    bb*i*bb
    b*iii*b
    *******

    ReplyDelete
  5. T11here are three 3x3 matrices, fill all these matrices randomly with the following letters
    R, G and B.All these matrices (Total 27 characters) to be filed.Now, display these three
    matrices.
    Your program has to match the following criteria:
     Arrangeeach matrix that should be filled with any one letter.Display the
    arrangement positions also (that swapping positions to be printed while
    arranging).
     Do the same process for the remaining letters, that should be filled in other
    matrices.
    B G G R G B B B R
    B R G B B R G R B
    G B R B G R R G R
    After arranging the letters in each matrix:
    R R R G G G B B B
    R R R G G G B B B
    R R R G G G B B B

    can i get this answer

    ReplyDelete
  6. please solve the C PROGRAM
    problem :Write a program to accept a string as command line argument and print the same.

    Sample Input (Command Line Argument) 1:
    Programming

    Sample Output 1:
    Programming - Command Line Arguments

    Sample Input (Command Line Argument) 2:
    Arguments

    Sample Output 2:
    Arguments - Command Line Arguments


    ReplyDelete
  7. bbb*bbb
    bb***bb
    b*****b
    *******
    b*****b
    bb***bb
    bbb*bbb

    ReplyDelete
  8. #include
    int main()
    {
    int n,i,j;
    scanf("%d",&n);
    for(i=0;i=j||j>=n*2-i)
    printf("b");
    else
    {
    if(i==0)
    {
    printf("*");
    }
    else
    {
    int k=i+1;
    if(k>=j || j>=n*2-k)
    {
    printf("*");
    }
    else
    {
    printf("i");
    }
    }
    }


    }
    printf("\n");
    }
    return(0);
    }

    this code is bit mess but it still work
    it's for
    *******
    b*iii*b
    bb*i*bb
    bbb*bbb

    ReplyDelete
    Replies
    1. Did you get the correct answer for above questions

      Delete
    2. hello dear mine is java, lets do it together as all ques are same in c , python, java of ebox

      Delete

Random password generator in Java

       Random password generator in Java Source code: mport java.io.*; import java.util.*; public class Main { public static void main(Str...