473,396 Members | 1,852 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.

yanghui triangle

how to print the follow one:
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
.........................

Mar 25 '06 #1
4 1815
wi*********@gmail.com opined:
how to print the follow one:
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
........................


In ISO Standard C, it's fairly easy:

#include <stdio.h>

int main(void)
{
printf("1\n");
printf("1 1\n");
printf("1 2 1\n");
printf("1 3 3 1\n");
printf("1 4 6 4 1\n");
printf("1 5 10 10 5 1\n);
printf("........................\n");

return 0;
}

Or did you mean algorithmically? In which case:

- this is a wrong group, try comp.programming
- a fee is chargeable for doing homeworks

--
BR, Vladimir

I guess I've been wrong all my life, but so have billions of
other people... Certainty is just an emotion.
-- Hal Clement

Mar 25 '06 #2
wi*********@gmail.com wrote:
how to print the follow one:
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
........................


printf("1\n1\t1\n1\t2\t1\n1\t3\t3\t1\n1\t4\t6\t4\t 1\n1\t5\t10\t10\t5\t1\n");

Mar 25 '06 #3
santosh opined:
wi*********@gmail.com wrote:
how to print the follow one:
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
........................


printf("1\n1\t1\n1\t2\t1\n1\t3\t3\t1\n1\t4\t6\t4\t 1\n1\t5\t10\t10\t5\t1\n");

Sorry, this does not work as OP wants. Mind the spacing. ;-)

--
BR, Vladimir

OCCAM'S ERASER:
The philosophical principle that even the simplest
solution is bound to have something wrong with it.

Mar 25 '06 #4
Vladimir S. Oka wrote:
santosh opined:
wi*********@gmail.com wrote:
how to print the follow one:
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
........................


printf("1\n1\t1\n1\t2\t1\n1\t3\t3\t1\n1\t4\t6\t4\t 1\n1\t5\t10\t10\t5\t1\n");

Sorry, this does not work as OP wants. Mind the spacing. ;-)


You're right. Didn't read close enough.

Mar 25 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: coinjo | last post by:
I need to write a program, which takes two inputs: •a value n that represents the number of elementsin the longest row of a triangle. •a character c to be printed in place of each...
16
by: VISHNU VARDHAN REDDY UNDYALA | last post by:
Hi, Could anyone over here, write a program in C using only for loop to print the following output * *** ***** ******* ********* ***********
2
by: javadkhan | last post by:
Hi All, I am trying to supress the small black triangle that shows up in the menus meaning the menuitem is parent. The reason for that is I drew my own 3D looking triangle in DrawItem using...
1
by: Leo | last post by:
Can someone tell me how to make the sorting triangle on datagrid column header always show up? And which property can change the color of the triangle ? The default color is white. Thanks
5
by: singhm | last post by:
Hi guys so I have a trianlge program having hard time finishing this though, I have to develop a program which is the following: Write a program that will allow the user to enter the 3 lengths...
0
geo039
by: geo039 | last post by:
I have a program that takes user input from a textbox. Based on those 3 numbers it will tell them whether it is a right triangle, equilateral triangle or not a triangle. I've written 3 constructors...
19
by: lost1 | last post by:
Can someone point me in the right direction on how to get the triangle type to display. Below is a triangle class that is tested by another completely separate class. The main method of the test...
6
by: jackj | last post by:
Hi, I am first time C++ student and doing the usual tasks. This one is to create a triangle based on user input of how large (how many rows) and what symbol to use. I have managed to create a...
2
by: nuimstudent | last post by:
Hey, I have to write a code which calculates pascals triangle using C. So Far I have the triangle with a right side allignment. As part of the assignment, we actually have to get the triangle to...
14
by: ginevralupin | last post by:
Puhleeeease check this ....... Isnt giving the correct output ... int a,b,c; printf("Enter the sides..."); scanf("%d %d %d",&a,&b,&c); if (a<(b+c)) printf("The triangle is...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.