这里给出n个路段,每个路段在建造建筑物的过程中有两个侧面。如果需要在两栋房屋之间留出一个空的空间,那么有多少种方法可以在地块中建造建筑物。
建造建筑物有四种可能性
路的一侧
路的另一边
不能建造建筑物
道路两边
Input: It takes the number of sections to construct buildings. Say the input is 3. Output: Enter Number of sections: 3 Buildings can be constructed in 25 不同的方法。
constructionWays(n)
输入:有n个部分。
输出-可能的方法数量。
Begin if n = 1, then return 4 countEnd := 1 countEndSpace := 1 for i := 2 to n, do prevCountEnd := countEnd prevCountEndSpace := countEndSpace countEndSpace := countEnd + prevCountEndSpace countEnd := prevCountEndSpace done answer := countEndSpace + countEnd return answer^2 End
#include<iostream> using namespace std; int constructionWays(int n) { if (n == 1) //if there is one section return 4; //4 possible ways to construct building in that section //设置末端的计数值,并以空格结尾 int countEnd=1, countEndSpace=1, prevCountEnd, prevCountEndSpace; for (int i=2; i<=n; i++) { //fot the second section to nth section prevCountEnd = countEnd; prevCountEndSpace = countEndSpace; countEndSpace = countEnd + prevCountEndSpace; countEnd = prevCountEndSpace; } //以空间和建筑结尾的可能方法 int answer = countEndSpace + countEnd; return (answer*answer); //for two sides the answer will be squared } int main() { int n; cout << "Enter Number of sections: "; cin >> n; cout << "Buildings can be constructed in " << constructionWays(n) <<" 不同的方法。" ; }
输出结果
Enter Number of sections: 3 Buildings can be constructed in 25 不同的方法。
Joomla是一个模型 - 视图 - 控制器Web应用程序。 在本章中,我们将讨论Joomla的架构风格。 下图显示了Joomla的架构。 Joomla的架构包含以下层 - Database Joomla框架 Components Modules Plugin Templates 网络服务器 Database - 数据库是数据的集合,可以以特定方式进行存储,操作和组织。 数据库存储用户信息,内容和
以下屏幕截图显示了Angular 2应用程序的解剖结构。 每个应用程序都包含组件。 每个组件都是应用程序功能的逻辑边界。 您需要具有分层服务,这些服务用于跨组件共享功能。 以下是组件的解剖结构。 一个组成部分包括 - Class - 这类似于C ++或Java类,它由属性和方法组成。 Metadata - 用于装饰类并扩展类的功能。 Template - 用于定义应用程序中显示的HTML视图。 以
Drupal是一个用于Web内容管理的平台,它是构建简单和复杂站点的强大工具。 在本章中,我们将讨论用于实现用户界面的Drupal的架构风格。 下图显示了Drupal的架构 - Drupal的架构包含以下层和miuns; Users Administrator Drupal PHP Web Server Database Users - 这些是Drupal社区的用户。 用户使用Drupal CMS
本章介绍了JFreeChart的基本类级别和应用程序级别体系结构,以便您了解JFreeChart如何与不同的类进行交互以及它如何适合基于Java的应用程序。 类级架构 类级体系结构解释了库中的各种类如何相互交互以创建各种类型的图表。 以下是上述框图中使用的单位的详细信息 - S.No 单位和描述 1 File 具有用于在文件中创建数据集的用户输入的源。 2 Database 具有用于在数据库中创建
Java Persistence API是将业务实体存储为关系实体的源。 它显示了如何将PLAIN OLD JAVA OBJECT(POJO)定义为实体以及如何管理具有关系的实体。 类级架构 下图显示了JPA的类级体系结构。 它显示了JPA的核心类和接口。 下表描述了上述体系结构中显示的每个单元。 单位 描述 EntityManagerFactory 这是EntityManager的工厂类。 它创
Tika的应用程序级架构 应用程序员可以轻松地将Tika集成到他们的应用程序中 Tika提供命令行界面和GUI,使用户友好。 在本章中,我们将讨论构成Tika架构的四个重要模块。 下图显示了Tika的架构及其四个模块 - 语言检测机制。 MIME detection mechanism. Parser interface. Tika Facade课程。 语言检测机制 每当文本文档传递给Tika时,
我正试图建立一个项目。NET 5.0使用Azure运营模式管道构建,我收到了此错误 有人知道Azure DevOps管道是否支持构建。NET5.0代码?