You are not logged in. Please login at www.codechef.com to post your questions!

×

generating numbers containing 0 and 1 only

i wished to write a code in c or c++ that could help me to generate numbers containing only two type of digits(say 0,1) till an appropriate limit (say 100000).eg.0,1,01,00,10,11,110,111,101...and so on.... without traversing from 0 to the actual range (by comparing the individual digits if they are 0 and 1).

asked 05 Apr '15, 16:12

tejasvi96's gravatar image

2★tejasvi96
1
accept rate: 0%

edited 05 Apr '15, 16:36


use rand()%2 to generate 0 or 1.

link

answered 06 Apr '15, 01:17

ironmandhruv's gravatar image

4★ironmandhruv
333239
accept rate: 20%

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×69

question asked: 05 Apr '15, 16:12

question was seen: 653 times

last updated: 06 Apr '15, 01:17