473,396 Members | 1,767 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

to print different types of pyramids with numbers

1
like

1
10
101
1001
10001

1
10
101
1010
10101
Aug 26 '10 #1
4 3512
johny10151981
1,059 1GB
I always suggest the new programmer
"If you want to make your computer to solve what you need, then first you figure it out- how you would solve it. Then implement it with the computer language."

The thing is if you dont know how you would do this. there is no real help for you.
Aug 26 '10 #2
whodgson
542 512MB
post some code to show how you would go about it.
Aug 26 '10 #3
whodgson
542 512MB
hint:
If s=0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1;
s.length()prints 16 so s.length/2=8*
If from the body of a for loop (with this end condition) you print a substr of s with a couple of simple arguments you may print a triangle of 0 and 1`s.
Aug 30 '10 #4
donbock
2,426 Expert 2GB
Is this the problem you're trying to solve:
Write a program that outputs N lines of text, with the ith line (1<=i<=N) consisting of a "1" followed by N-i random digits, where the random digits are either "0" or "1".
Aug 30 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: alg | last post by:
Is it possible to put different types of objects in a single STL list? If not what STL template should be used which will contains various objects of different types? Thanks for your help!
9
by: Nils Petter Vaskinn | last post by:
Why is it that if I have an overloaded function like: void foo(int i); void foo(char *c); I can't do: void bar() { foo( condition ? 5 : "NULL"); }
7
by: Office Drone | last post by:
I'm a bit confused about memory usage, and for some reason I wasn't able to find a single point-of-call to get the amount of memory available. If we take, for instance, the Windows platform: ...
4
by: m | last post by:
Hello I need to use sth. like container for different types of variables. Is sth like this in c++ STL? ----|----------|--|----|------|etc. var1| var2 |v3|var4| var5 |etc. int | float...
17
by: tuvok | last post by:
How can objects of different types be stored in a collection? For example: struct S1 { /*...*/ }; struct S2 { /*...*/ }; struct Sn { /*...*/ }; template<typename T> class X { public:
6
by: Anders Würtz | last post by:
i have an assignment to iterate through a collection containing different types of numeric values (float, double, int, byte, short etc.) and to add 1 to all of them. I tried with array and...
20
by: pinkfloydhomer | last post by:
Is it well-defined and portable to do something like: typedef struct { int type; char c; } S1; typedef struct {
4
by: Dmitry Kulinich | last post by:
Guys! Is there are any possibility to create nodes with duplicate names and different types in XSD? I've read the whole specification and tried in a many different ways, but not successfull. ...
8
by: Born Bugler | last post by:
What I'm actually talking about is, when you put the same class in different assemblies, you get two different types. This is reasonable (if you would call it) in most cases as it avoids possible...
15
by: Juha Nieminen | last post by:
I'm sure this is not a new idea, but I have never heard about it before. I'm wondering if this could work: Assume that you have a common base class and a bunch of classes derived from it, and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.