C++
文章平均质量分 62
yuan_crazycode
Target website construction and application development of coder
展开
-
C++:编写一个程序,用动态分布分配空间的方法计算Fibonacci数列的前二十项并存储到动态分布的空间中
#include //预操作using namespace std;// 使用命名空间stdint main(){int i,sum=0;int *p;p = new int[20];*p = 0;*(p + 1) = 1;for (i = 0; i {*(p + i + 2) = *(p + i) +*(p+i+1);}cout for原创 2016-05-15 12:10:17 · 12039 阅读 · 1 评论 -
C++:建立一个被称为sroot()的函数,返回其参数的二次方根。重载sroot()3次,让它返回整数、长整数与双精度的二次方根
#include //预操作#includeusing namespace std;// 使用命名空间stddouble sroot(int a){ return (sqrt(a));}double sroot(long b){ return (sqrt(b));}double sroot(double c){ return sqrt(c);}int main()原创 2016-05-15 18:02:51 · 8246 阅读 · 0 评论 -
C++:输入两个整数,将它们按从小到大的顺序输出(使用变量的引用)
#include //预操作#includeusing namespace std;// 使用命名空间stdvoid min(int &c, int &d){ if (c > d) { cout << d << " " << c << endl; } else if (c < d); { cout << c << " " << d << endl; } if(c=原创 2016-05-15 18:24:16 · 17265 阅读 · 0 评论 -
C++:将一元人民币兑换成1、2、5分的硬币,求换法
#include //预操作#includeusing namespace std;// 使用命名空间stdint main(){ int i, j, k; int sum = 0; int a = 1, b = 2, c = 5; cout << "The algorithms are :" << endl; cout << "penny" << "\t" << "two原创 2016-05-15 18:43:37 · 12019 阅读 · 0 评论