Skip to main content

Number Pattern

 /* @ToDo 


   Number Pattern
                1       
            1       2       
        1       2       3       
    1       2       3       4       
1       2       3       4       5       

   
*/


#include <iostream>
using namespace std;

int main(){
     #ifndef ONLINE_JUDGE
        freopen("../asset/input.txt","r",stdin);
        freopen("../asset/output.txt","w",stdout);
    #endif
    // Code here!!

   int ncin>>n;
   for(int i=1;i<=n;i++){
       for(int j=0;j<n-i;j++)
        cout<<"\t";
        for(int j=1;j<=i;j++)
            cout<<j<<"\t\t";
        cout<<endl;  
   }

    return 0;
}

Comments

Must Read:

Arrange Buildings

1. You are given a number n, which represents the length of a road. The road has n plots on it's each side. 2. The road is to be so planned that there should not be consecutive buildings on either side of the road. 3. You are required to find and print the number of ways in which the buildings can be built on both side of roads. Input Format A number n Output Format A number representing the number of ways in which the buildings can be built on both side of roads. Constraints 0 < n <= 45 Sample Input 6 Sample Output 441 Solution: import java.io.*; import java.util.*; public class Main{ public static void main(String[] args) throws Exception {     // write your code here     Scanner scn = new Scanner(System.in);     long n = scn.nextInt();     long ob = 1;     long os = 1;     for (int i = 2; i <= n; i++) {       long nb = os;       long ns = os + ob;       ob = nb;   ...

Coin Change Combination

1. You are given a number n, representing the count of coins. 2. You are given n numbers, representing the denominations of n coins. 3. You are given a number "amt". 4. You are required to calculate and print the number of combinations of the n coins using which the       amount "amt" can be paid. Note 1: You have an infinite supply of each coin denomination i.e. same coin denomination can be                    used for many installments in payment of "amt" Note 2: You are required to find the count of combinations and not permutations i.e.                   2 + 2 + 3 = 7 and 2 + 3 + 2 = 7 and 3 + 2 + 2 = 7 are different permutations of same                    combination. You should treat them as 1 and not 3. Input Format A number n n1 n2 .. n number of elements A number amt Output Format A number representing the count of ...

Algorithm Analysis and Design Concepts Hands-On | Replace Character

 Algorithm Analysis and Design Concepts  Hands-On  Replace Character String – Replace Characters   Write a recursive function 'public static String replace(String str,char from,char to) ' that changes all occurrences of 'from' in ‘str’ to ‘to’. For example, if str were "codebook ", and from = 'o' and to = 'e', then, str would become "cedebeek". F unction Definitions: public static String replace(String str, char from, char to) Problem Requirements: Keyword Min Count Max Count for 0 0 while 0 0   Note:  Create the main() inside the class 'ReplaceDriver' Refer sample input and output for formatting specifications. Sample Input and Output : Enter the string Asia Enter the character to be replaced a Enter the character to be replaced with i The modified string is Asii Evaluation Result: Result Description Summary of tests *Note: All the test cases might not have same weightage +------------------------------+ | 8 tests run/ 8 t...

Software Engineering Concepts Hands-On

  Software Engineering Concepts  Hands-On

Subscribe to Get's Answer by Email