C/C++程序设计
KogRow
这个作者很懒,什么都没留下…
展开
-
C++之虚函数作用初步认识
虚函数可以让成员操作一般化看一段代码:#include<iostream>using namespace std;class B0{ public: void display(){cout<<"B0::display()"<<endl;}};class B1:public B0{ public: ...原创 2020-04-14 12:56:12 · 176 阅读 · 0 评论 -
GCC报错:invalid use of member 'char node::getData()' (did you forget the '&' ?)的一种可能原因
最近用C++写代码,GCC编译。静态检测没有错误,执行时GCC报错如下:{ "resource": "/c:/Users/fuck/Documents/CLanguage/c:/Users/fuck/Documents/CLanguage/test.cpp", "owner": "cpptools", "severity": 8, "message": "i...原创 2020-03-21 12:08:22 · 3364 阅读 · 0 评论 -
C++以类的形式实现链表
#include<iostream>using namespace std;class node{private: public: char data; node* next; node(){ this->next = NULL; } // void setData(char c){this->d...原创 2020-03-21 11:37:22 · 412 阅读 · 0 评论 -
C++实践之输出所有水仙花数
水仙花数是一个三位数,各数字的立方和等于该数本身代码:#include<iostream>#include<cmath>#include<iomanip>using namespace std;int main(){ //从100开始 for(int i=1;i<10;i++){ for(int j=0;j...原创 2020-03-10 17:33:25 · 1676 阅读 · 0 评论 -
C++实践之华氏温度转摄氏温度
#include<iostream>#include<cmath>#include<iomanip>using namespace std;int main(){ cout<<"输入华氏温度"<<endl; double F; cin >> F; double F2C(double F...原创 2020-03-10 17:27:32 · 10397 阅读 · 1 评论 -
C++实践之计算圆周长、圆面积、球体积、球面积、圆柱体积
0x00题目设圆半径r=1.5,圆柱高h=3,求圆周长、圆面积、圆球体积、圆球面积、圆柱体积用cin输入数据,取小数点后两位数字.0x01代码#include<iostream>#include<cmath>#include<iomanip>using namespace std;int main(){ cout<<...原创 2020-03-10 17:22:25 · 5840 阅读 · 0 评论 -
C++实践之计算Fibonacci数列前n项
0x00Fibonacci数列第一、第二项为1、1从第三项开始,每一项是前面两项之和0x01程序输入输出输入:需要计算的项数num、存储斐波纳契数列前n项的数组指针list输出:list0x02代码#include<iostream>using namespace std;int main(){ int count = 40; int ...原创 2020-03-10 16:41:20 · 3354 阅读 · 0 评论 -
C语言实践之判断数组是否为可分割
如果列表中的两个索引之间有一个位置,其中一边的 数字之和等于另一边的数字之和,那么我们将列表定 义为可分割的。将非空列表作为输入,编写一个函数, 该函数在且仅当列表可分割时返回 1,否则返回0上代码:#include <stdio.h>int part(int *list);int getLength(int *list);int main(){ int ...原创 2020-03-05 16:34:23 · 303 阅读 · 0 评论