![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
cpp之路
无
rUShUAn
啥都不会
展开
-
简易导航系统
#include<iostream>using namespace std;#include<fstream>#include<string>#include<stdio.h>#include<math.h>bool visit[26] = { false };int record[26] = {0};int minpath[26] = { 0 };int temp = 0;int rec...原创 2021-10-09 00:13:39 · 342 阅读 · 0 评论 -
printf函数
会把空格补在数字前面C语言printf函数(基础)_哔哩哔哩_bilibili原创 2021-09-06 20:37:23 · 54 阅读 · 0 评论 -
scanf函数
格式:scanf(格式控制字符串,变量地址表)e.g. scanf("%d%d",&a,&b);格式控制字符串:用于规定变量的输入格式。变量地址表:存储数据的变量的地址(为是么用变量地址作参数?是由C语言中的参数的单向传递规则决定的)...原创 2021-09-06 20:15:07 · 116 阅读 · 0 评论 -
简易机器翻译器
背景:在一些比较秘密的场景中,为了传输一些重要的数值串(例如美国新冠病毒实际死亡人数),相关人员往往将这些数据保存为字符串、数值以及各种符号混用的形式。在实际需要这些数据时,就通过提前定义好的方法将它们翻译回来。相应的子程序:[1] 计算n![2] 求最小公倍数和最大公约数[3] 输入某雇员每周工作时间(以小时计)和每小时工资数,计算并输出其工资。(如果时间小于0或大于一周的总时间直接输出0)。若雇员每周工作小时超过60小时,则超过60小时的部分按原工资3倍的加班工资来计算,雇员每周工作原创 2021-07-01 10:17:28 · 1002 阅读 · 0 评论 -
Warshall算法求传递闭包
#include <iostream>using namespace std;void Warshall(){ int n, ** p, judge; cout << "*使用Warshall算法求传递闭包*" << endl; cout << "请输入顶点个数n:"; cin >> n; p = new int* [n]; for (int i = 0;i < n;i++) { p[i] = new int[n];.原创 2021-06-28 11:17:40 · 147 阅读 · 0 评论 -
容器list
1.基本概念原创 2021-06-19 22:42:58 · 52 阅读 · 0 评论 -
容器 vector
Vector存放内置数据类型#include<iostream>using namespace std;#include<vector>#include<algorithm> void myPrint(int val){ cout << val << endl;}void test01(){ vector<int>v; v.push_back(10); v.push_back(20); v.push_b原创 2021-06-19 11:58:27 · 78 阅读 · 0 评论 -
输入输出流
一.写文件#include<iostream>using namespace std;#include<fstream>//头文件包含//文本文件 写文件void test01(){ //1.包含头文件 fstream //2.创建流对象 ofstream ofs; //指定打开方式 ofs.open("test.txt", ios::out); //4.写内容 ofs << "姓名:张三" << endl; ofs &l.原创 2021-06-16 00:18:00 · 86 阅读 · 0 评论 -
something about 类模板
·类模板中成员函数的创建时机类模板中的成员函数并不是一开始就创建的,而是在调用时才去创建。#include<iostream>using namespace std;class Person1{public: void showperson1() { cout << "person1 show" << endl; }};class Person2{public: void showperson2() { cout <&.原创 2021-06-14 22:21:40 · 72 阅读 · 0 评论 -
模板-排序打印
#include <iostream>using namespace std;template<class T>void mySwap(T& a, T& b){ T temp = a; a = b; b = temp;}template <class T>void mySort(T arr[],int len){ for (int i = 0;i < len;i++) { int max = i; for (int.原创 2021-06-11 20:04:33 · 49 阅读 · 0 评论 -
黑马程序员-类和多态-多态
黑马程序员53.多态的基本语法#include <iostream>using namespace std;//多态class Animal{public: virtual void speak() { cout << "动物在说话" << endl; }};class Cat :public Animal{public: void speak() { cout << "小猫在说话" << endl;原创 2021-06-01 17:29:28 · 189 阅读 · 0 评论 -
图形面积计算(继承)+n边形的周长(注意怎么new的?)
#include <iostream>#include <time.h>#include <iomanip>using namespace std;class Graph{public: Graph(string Name = ""):name(Name) {}; virtual double Area() { return area; }; friend ostream& operator<<(ostream& outpu.原创 2021-05-31 23:30:50 · 86 阅读 · 0 评论 -
虚函数(课后两个习题)
圆球圆柱、教职工工资#include <iostream>using namespace std;class circle{public: circle(double r) { radius = r; } virtual double area() { return 0; } virtual double volume() { return 0; } double pi = 3.14;protected: double radius;};class sphere :原创 2021-05-30 11:36:33 · 78 阅读 · 0 评论 -
继承、类、new指针数组、随机数
题目#include <iostream>#include <stdlib.h>#include <time.h>#include <iomanip>using namespace std;string t = "\t";class Student{protected: int Id, Eng, Math; double Average;public:};class CS :public Student{protecte原创 2021-05-24 19:58:51 · 79 阅读 · 0 评论 -
类的杂七杂八2
有理数(分数)、三维向量的运算#include <iostream>using namespace std;//有理数的加减乘除运算class Rational{private: int c1, c2;public: Rational(int, int); Rational(const Rational& c); void Add(const Rational c); void Minus(const Rational c); void Multiply(c原创 2021-05-23 18:19:24 · 43 阅读 · 0 评论 -
类的杂七杂八1
//初始化Person(int a,int b,int c):A(a),B(b),C(c){}//调用Person p(1,2,3)注意冒号在哪#include<iostream>#include<string>using namespace std;//类对象作为类成员//手机类class Phone{public: string m_PName; Phone(string pName) { m_PName = pName; } /..原创 2021-04-29 23:32:40 · 51 阅读 · 0 评论 -
类、构造函数、复制构造函数、排序
#include<iostream>using namespace std;class Student{private: int id; string name; int age; double cpp; double eng; double math; double average;public: double sum; Student(int, string, int, double, double, double); Student(const Stu.原创 2021-04-28 00:07:27 · 70 阅读 · 0 评论 -
一个简单的排序题
1. 从键盘输入一个正整数n,利用随机函数产生n个10~10000之间的整数并放入一个n维动态数组array中;2、 编写函数void Print(int* p, int k),该函数的功能是显示数组p中的整数,函数的实现过程要求采用指针进行处理,其中k是数组中元素的个数;3、对数组array进行排序,并使用Print函数显示数组array的内容以验证排序的正确性;4、从键盘输入一个10~1000之间的整数m,把m插入到已排序的数组array中,要求插入后数组中的整数仍然保持有序,使用Pr..原创 2021-04-15 22:56:55 · 702 阅读 · 3 评论 -
杨辉三角(动态存储)
【代码】杨辉三角(动态存储)原创 2021-04-15 15:45:20 · 148 阅读 · 0 评论 -
统分、排序、查分
T:某班期末考试科目为数学(MT)、英语(EN)和物理(PH),有最多不超过30人参加考试。考试后要求:(1)计算每个学生的总分和平均分;(2)按总分成绩由高到低排出成绩的名次;(3)打印出名次表,表格内包括学生编号、各科分数、总分和平均分;(4)任意输入一个学号,能够查找出该学生在班级中的排名及其考试分数。...原创 2021-04-12 23:51:34 · 709 阅读 · 1 评论 -
矩阵相乘
#include<iostream>#include<iomanip>using namespace std;int cul(){ const int a = 3, b = 3, c = 3, d = 2; long ar1[a][b], ar2[c][d], ar3[c][d] = {}; cout << "请按行输入3*3的矩阵A的元素:" << endl; for (int i = 0;i < 3; i++) { fo...原创 2021-04-09 12:48:02 · 61 阅读 · 1 评论 -
猜数字游戏(随机生成数字、重复游戏)
#include <iostream>#include <stdlib.h>#include <time.h>using namespace std;void guess(){ srand(time(0)); int number = rand() % 2000+1 ; int count = 0; int a = 0; while (a != number && count < 10) { cout <<.原创 2021-03-23 10:05:40 · 903 阅读 · 0 评论 -
二进制转十进制(cin.get)
#include <iostream>using namespace std;int main(){ int Dec = 0; char ch; cout << "Binary="; do{ cin.get(ch); } while (ch != '0' && ch != '1'); do { Dec += ch - '0'; cin.get(ch); .原创 2021-03-15 16:18:15 · 178 阅读 · 1 评论 -
函数的值传递
交换数字函数#include <iostream>using namespace std;void swap(int num1, int num2){ cout << "交换前:" << endl; cout << "num1=" <<num1<< endl; cout << "num2=" << num2<< endl; int temp = num1;原创 2021-03-08 17:19:38 · 49 阅读 · 0 评论 -
输入n位数,找出最大数;统计分数(二维数组)
输入n位数,找出最大数;统计分数(二维数组)#include <iostream>using namespace std;int main() { int i, n; double x, max; cout << "n="; cin >> n; cin >> x; max = x; for(i=2;i<=n;i++) { cin >> x;原创 2021-03-04 20:38:16 · 77 阅读 · 0 评论 -
九九乘法表
#include <iostream>using namespace std;int main() { for (int i = 1;i <= 9;i++) { for (int j = 1;j <= i;j++) { cout << j << "*" << i << "=" << j * i <<" "; } .原创 2021-02-14 12:21:04 · 44 阅读 · 0 评论 -
计算π近似值(do-while)、for、for嵌套
#include <iostream>using namespace std;#include<cmath>int main(){ long long int i; double sum, term, pi; sum = 1;i = 1; do { i += 1; term = 1.0 / (i * i); sum += term; } while (term .原创 2021-02-13 10:40:54 · 611 阅读 · 0 评论 -
switch 分段函数、do-while、水仙花数
#include <iostream>using namespace std;#include<cmath>int main(){ { double x, y; cout << "x="; cin >> x; switch (int(x)) { case 1:y = 3 * x - 5;break; case 2: case 3:y = 2*cos(x)+1;break; c.原创 2021-02-10 19:45:10 · 231 阅读 · 0 评论