如何用C语言解决 [英] How to solve in C language

查看:91
本文介绍了如何用C语言解决的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在其他应用程序中,Pascal的三角形提供了一种方法,用于确定每次采集的n个事物的可能组合的数量。例如,五个人(n = 5)的可能组合数量一次取两个

(r = 2)为10.

三角形的每一行开始和结束1.连续的每一个元素都是它上面的元素和它上面的元素左边的元素的总和。也就是说,element [n] [r] = element [n-1] [r] + element [n-1] [r-1]

使用此信息,编写并测试C ++程序创建表示Pascal三角形的二维数组的前11行。对于n小于11且r小于或等于n的任何给定值,程序应显示正确的元素。使用您的程序来确定从10人中选出一个8人委员会的方式。



我尝试过的方法:



[我试图在这里发布问题]

Among other applications, Pascal’s triangle provides a means of determining the number of possible combinations of n things taken r at a time. For example, the number of possible combinations of five people (n = 5) taken two
at a time (r = 2) is 10.
Each row of the triangle begins and ends with 1. Every other element in a row is the sum of the element directly above it with the element to the left of the one above it. That is, element[n][r] = element[n-1][r] + element[n-1][r-1]
Using this information, write and test a C++ program to create the first 11 rows of a two-dimensional array representing Pascal’s triangle. For any given value of n less than 11 and r less than or equal to n, the program should display the correct element. Use your program to determine in how many ways a committee of 8 can be selected from a group of 10 people.

What I have tried:

[I tried to post the problem here]

推荐答案

我们不做你的HomeWork。

HomeWork不会测试你乞求别人做你的工作的技巧,它会让你思考并帮助你的老师检查你对你所学课程的理解,以及你应用它们时遇到的问题。

你的任何失败都会帮助你的老师发现你的弱点并设置补救措施。

你的陈述详细描述了三角形的构建方式。

所以,试一试,重读课程并开始工作。如果您遇到特定问题,请显示您的代码并解释这个问题,我们可能会提供帮助。



作为程序员,您的工作是创建算法解决特定问题,你不能依赖别人永远为你做,所以有一段时间你必须学会​​如何。而且越快越好。

当你要求解决方案时,就像试图通过培训其他人来学习开车一样。

创建算法基本上是找到数学并进行必要的调整以适应你的实际问题。
We do not do your HomeWork.
HomeWork is not set to test your skills at begging other people to do your work, it is set to make you think and to help your teacher to check your understanding of the courses you have taken and also the problems you have at applying them.
Any failure of you will help your teacher spot your weaknesses and set remedial actions.
Your statement describe with details how the triangle is build.
So, give it a try, reread your lessons and start working. If you are stuck on a specific problem, show your code and explain this exact problem, we might help.

As programmer, your job is to create algorithms that solve specific problems and you can't rely on someone else to eternally do it for you, so there is a time where you will have to learn how to. And the sooner, the better.
When you just ask for the solution, it is like trying to learn to drive a car by having someone else training.
Creating an algorithm is basically finding the maths and make necessary adaptation to fit your actual problem.


会员12446680写道:
Member 12446680 wrote:

使用这些信息,编写并测试一个C ++程序

Using this information, write and test a C++ program

这显然是你的作业任务,直接从你的课程作业或教师的电子邮件中复制。是时候开始思考并做自己的工作了。

That is obviously your homework assignment copied straight from your coursework, or teacher's email. Time to get your thinking cap on and do your own work.


好吧,至少第一项任何一行都知道 1 ,因此

Well, at least the first item any row is know to be 1, hence
t[0][0] = 1
t[1][0] = 1

现在,表达式

now, the expression

t[n][k] = t[n-1][k] + t[n-1][k-1]



for item t [1] [ 1] ,它直接转换为


for item t[1][1], it directly translates to

t[1][1] = t[0][1] + t[0][0] = 1 + 1 = 2;



等等。





现在,您不必是 C ++ 的主人,以便在代码中实现它。


and so on.


Now, you haven't to be a master of C++ in order to implement it in code.


这篇关于如何用C语言解决的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆