(3)使用有默认参数的构造函数,不给定实参时,默认边长为1;注意——这个版本也只需要一个构造函数即可。需要的测试函数是:
int main(){
Triangle Tri1; //定义边长为1 1 1的三角形类实例
Tri1.showMessage();
Triangle Tri2(1.5);//定义边长为1.5 1 1的三角形类实例
Tri2.sho...
分类:
其他好文 时间:
2015-03-31 14:50:21
阅读次数:
136
标题:Triangle通过率:27.1%难度:中等Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.F...
分类:
其他好文 时间:
2015-03-30 20:59:18
阅读次数:
113
GivennumRows, generate the firstnumRowsof Pascal's triangle.For example, givennumRows= 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]...
分类:
其他好文 时间:
2015-03-30 10:51:47
阅读次数:
104
1008 A Very Easy Triangle Counting Game 1 /*题意:在圆上取n个点,相邻两个点之间连线,(注意,n和1相邻),然后所有点对(i ,i+2)相连,问能形成的不同的三角形有多少个? 2 3 思路:画图找规律,发现n=3,cnt=1; n=4,cnt=8; n.....
分类:
其他好文 时间:
2015-03-30 10:50:25
阅读次数:
107
1.带参数的构造函数
*Copyright (c)2015,烟台大学计算机与控制工程学院
*All rights reserved.
*文件名称:sum123.cpp
*作 者:林海云
*完成日期:2015年3月29日
*版 本 号:v2.0
*
*问题描述: 使用带参数构造函数,即Triangle(double x,double y,double z),三边长
...
分类:
其他好文 时间:
2015-03-30 09:37:42
阅读次数:
117
TriangleTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 0Accepted Submission(s): 0 Problem Descri...
分类:
其他好文 时间:
2015-03-28 20:10:15
阅读次数:
131
这题用n^2的算法能过,先任意枚举两点,和圆心组成的三角形求面积,这个面积可能会被加(n - 2)次,但是要注意,如果有3点是在同一侧,那么要减去,于是在枚举一遍,每次枚举一个点,然后枚举和这个点度数相差180以内的点,求面积,这个面积要减去2 * (j - i + 1)次
代码:
#include
#include
#include
#include
using namespace ...
分类:
其他好文 时间:
2015-03-28 10:07:48
阅读次数:
154
利用多文件组织,重新实现项目2。其中,整个项目包括3个文件:
主文件: main.cpp,用于定义main()函数
头文件: triangle.h,头文件,声明类,定义内置成员函数
类定义文件: triangle.cpp,用于定义类Triangle中其他成员函数
注意,将3个set函数和3个get函数设计成内置成员函数,其他函数不作为内置函数。
main.cpp
/*
* Copyri...
分类:
其他好文 时间:
2015-03-22 10:40:28
阅读次数:
419
Exact same as I. 1 class Solution { 2 public: 3 vector getRow(int rowIndex) { 4 if (rowIndex (); 5 vector result(1, 1); 6 ...
分类:
其他好文 时间:
2015-03-21 18:37:00
阅读次数:
126
Given an indexk, return thekthrow of the Pascal's triangle.For example, givenk= 3,Return[1,3,3,1].Note:Could you optimize your algorithm to use onlyO(...
分类:
其他好文 时间:
2015-03-21 16:45:27
阅读次数:
114