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); }
thank u for sharing this post Meraki Firewall
ReplyDeleteMeraki Cloud
// Considering n as a generalized input from the user.
ReplyDeleteimport 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();
}
}
}
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.
DeleteThe 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
*******
Plz give the code
DeleteCode
Delete#include
Deleteusing 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;
}
int n = s.nextInt();
Deleteint 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();
}
Plse tell in python
Deletehow many ques u have solved till now, mine java bt all ques are same, we can do it together
Deletesir can you tell me the solution for this problem
ReplyDeletebbbb*bbbb
bbb***bbb
bb*****bb
b*******b
*********
please tell the solution of this problem
#include
Deleteint 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;
}
#include
ReplyDeleteint 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;
}
It's not working
ReplyDeletesir can u tell me the solution for the below
ReplyDeletebbb*bbb
bb*i*bb
b*iii*b
*******
can any one help to find solution for this
DeletePlz help the above problem
DeleteT11here are three 3x3 matrices, fill all these matrices randomly with the following letters
ReplyDeleteR, 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
please solve the C PROGRAM
ReplyDeleteproblem :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
bbbb*
ReplyDeletebbb**
bb***
b****
*****
Code
Deletebbb*bbb
ReplyDeletebb***bb
b*****b
*******
b*****b
bb***bb
bbb*bbb
Solve
Delete#include
ReplyDeleteint 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
Error
DeleteDid you get the correct answer for above questions
Deletehello dear mine is java, lets do it together as all ques are same in c , python, java of ebox
Delete