Skip to main content

0-1 Pattern

 /* @ToDo 



0-1 Pattern
    1
    0   1
    0   1   0
    1   0   1   0
    1   0   1   0   1

*/


#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;
    int sign = 1;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=i;j++){
            cout<<"\t"<<sign;
            sign = !sign;
        }
        cout<<endl;
    }
    return 0;
}

Comments

Must Read:

Pyramid

/*  To Print  1    2   2    3   3   3    4   4   4   4    5   5   5   5   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   n ;  cin >> n ;      for ( int   i = 1 ; i <= n ; i ++){          for ( int   j = 1 ; j <=  i ; j ++){     ...

Zero One Knapsack | Recursion

 1. You are given a number n, representing the count of items. 2. You are given n numbers, representing the values of n items. 3. You are given n numbers, representing the weights of n items. 3. You are given a number "cap", which is the capacity of a bag you've. 4. You are required to calculate and print the maximum value that can be created in the bag without       overflowing it's capacity. Note: Each item can be taken 0 or 1 number of times. You are not allowed to put the same item again and again. Input Format A number n v1 v2 .. n number of elements w1 w2 .. n number of elements A number cap Output Format A number representing the maximum value that can be created in the bag without overflowing it's capacity Constraints 1 <= n <= 20 0 <= v1, v2, .. n elements <= 50 0 < w1, w2, .. n elements <= 10 0 < cap <= 10 Sample Input 5 15 14 10 45 30 2 5 1 3 4 7 Sample Output 75 Solution: import java.io.*; import java.util.*; public class Main...

Butterfly Pattern

  /* @ToDo  Butterfly Pattern     *                                   *     *   *                           *   *     *   *   *                   *   *   *     *   *   *   *           *   *   *   *     *   *   *...

UNIX Introduction to Unix | Post-Quiz

 UNIX  Introduction to Unix  Post-Quiz  Feedback Congratulations! You have passed by securing more that 80%. Question  1 Correct Mark 1.00 out of 1.00 Flag question Question text  What is the default maximum number of processes that can exist in Unix? Select one: a.  unlimited b.   32768           c.   4096        d.  1024          Feedback Your answer is correct. The correct answer is:  32768         Question  2 Correct Mark 1.00 out of 1.00 Flag question Question text Single user mode shell has _____ prompt.  Select one: a.   $ Normal user  b.  % Admin user c.  ~ Home user d.  # Root user    Feedback Your answer is correct. The correct answer is: # Root user  Question  3 Correct Mark 1.00 out of 1.00 Flag question Question text Predict the output for the following...

Accenture Mock Quiz | Part 2

  Question  10 Incorrect Marked out of 1.00 Flag question Question text Tom and his team uses the SVN(Configuration Management Tool) to do versioning of source code. Tom has pulled out the code from the SVN server to his local machine, updated his task partially and wanted to update the work back to the SVN server. What is the actual process Tom has performed with the SVN server. Select one: a.  fork/join   b.  check out/check in c.  commit/rollback d.  check in/check out Feedback The correct answer is: check out/check in Question  11 Incorrect Marked out of 1.00 Flag question Question text Software was developed for Global Marketing. Few changes that was earlier requested was already incorporated in the delivered software. Now the client does not want the changes and requested for the previous release. Which of the below option would facilitate developer to meet the client needs. Select one: a.  Software Control Management   b.  So...

Data Formats ( XML & JSON ) XML AND JSON | Generate XSD For Mobile Store

  Generate XSD For Mobile Store <?xml version="1.0" encoding="UTF-8"?> <mobilestore> <mobile> <brand>Nokia</brand> <os>Symbian</os> <model>C6</model> <ram>1gb</ram> <internal>8gb</internal> </mobile> <mobile> <brand>Samsung</brand> <os>Android</os> <model>Galaxy</model> <ram>2gb</ram> <internal>8gb</internal> </mobile> <mobile> <brand>Sony</brand> <os>Android</os> <model>Experia</model> <ram>512mb</ram> <internal>16gb</internal> </mobile> </mobilestore> <? xml  version = "1.0"  encoding = "UTF-8" ?> < xs:schema   xmlns:xs = "http://www.w3.org/2001/XMLSchema"   elementFormDefault = "qualified"   attributeFormDefault = "unqualifi...

Mock 3 Slot3 - Quiz - 21st July Quiz Quiz

Mock 3 Slot3        Quiz - 21st July          Important Questions

If a Prime Number

  /* @ToDo     If a Prime Number    9 => Not a Prime Number    7 => Prime Number */ #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   n ;  cin >> n ;     bool   flag  =  true ;     for ( int   i = 2 ; i * i <= n ; i ++)      if ( n % i == 0 ){          flag  =  false ;          break ;   ...

Programming using Java Hands On - Arrays | Find & Display the position of a number

  Write a java program to find the given number from the array of elements and display its position. If the number is not present in an array then display it as 0. Assume the position starts from 1. Sample Input 1 Enter the array size 4 Enter the values 9 32 17 4 Enter the number to find 17 Sample Output 1 3 Sample Input  2 Enter the array size 3 Enter the values 29 53 11 Enter the number to find 49 Sample Output  2 0 Result Description Summary of tests *Note: All the test cases might not have same weightage +------------------------------+ |4 tests run / 4 tests passed | +------------------------------+ TEST CASE PASSED

Subscribe to Get's Answer by Email