编程语言_C++
hnfeng2014
这个作者很懒,什么都没留下…
展开
-
王桂林 C++基础与提高 练习题——格式时钟输出(实时的,精确到秒)
这里直接使用了 localtime 函数获取 tm 时间然后做显示。代码如下: #include <iostream> #include <windows.h> #include "time.h" #include <process.h> using namespace std; void Clock() { struct tm *ptr; ...原创 2018-08-26 10:46:12 · 398 阅读 · 0 评论 -
王桂林 C++基础与提高 练习题—— 函数做默认参数
在王桂林老师给的样例上稍微做了调整。 王老师给的样例是: typedef int(*Comp)(int, int); void popSort(int *p, int len, Comp com=ascend); 我最终实现为如下的代码: #include <iostream> using namespace std; typedef void(*Exchange)(int...原创 2018-08-26 11:35:51 · 460 阅读 · 0 评论 -
王桂林 C++基础与提高 练习题——string数组
题目:读取字符数组 char buf[100] = char buf[100] = "xxxxx:yyyyy:zzzzz:aaaa:bbbb"; 按 : 分解到string数组中去。 自己实现总觉得哪里不得劲,尤其是获取:个数和给string数组赋值这两处。走过路过帮忙指点一二,谢谢。 自己实现的代码如下: #include <iostream> #include <st...原创 2018-08-26 12:35:24 · 358 阅读 · 0 评论 -
王桂林 C++基础与提高 练习题——类实现单向链表的封装
源码: fhnClassList.h #ifndef _FHN_CLASS_LIST_ #define _FHN_CLASS_LIST_ #pragma once struct Data { int a; int b; }; struct Node { Data d; struct Node* next; }; class fhnClassList { ...原创 2018-08-26 16:15:35 · 204 阅读 · 0 评论 -
王桂林 C++基础与提高 练习题——求两点间的距离
定义一个Point类,其属性包含点的坐标,提供计算两点间距离的方法。 #include <iostream> #include <math.h> using namespace std; class Point { public: Point() { } Point(double a, double b):x(a),y(b) ...原创 2018-09-01 15:09:30 · 338 阅读 · 0 评论 -
王桂林 C++基础与提高 练习题——按需求设计一个圆类
其属性包含圆心和半径 创建两个圆形对象,提示用户输入圆心和半径,判断两圆是是否相交 main.cpp #include <iostream> #include <math.h> #include "fhnClassList.h" using namespace std; int main() { double x = 0.0; double y ...原创 2018-09-01 16:10:19 · 254 阅读 · 0 评论