- 博客(6)
- 资源 (1)
- 收藏
- 关注
原创 王桂林 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
284
原创 王桂林 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
375
原创 王桂林 C++基础与提高 练习题——类实现单向链表的封装
源码:fhnClassList.h#ifndef _FHN_CLASS_LIST_#define _FHN_CLASS_LIST_#pragma oncestruct Data{ int a; int b;};struct Node{ Data d; struct Node* next;};class fhnClassList{...
2018-08-26 16:15:35
230
原创 王桂林 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
390
原创 王桂林 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
499
原创 王桂林 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
441
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人