c++
酱油瓶被人注册了
这个作者很懒,什么都没留下…
展开
-
C++中const在函数名前面和函数后面的区别
看一道题先:#include <iostream>using namespace std;struct A{ int v; A(int vv):v(vv) { } // 在下面补充完struct const A* getPointer() const{ return this; }};int main(){ ...转载 2018-04-02 20:55:47 · 1471 阅读 · 0 评论 -
PAT - 1145 Hashing - Average Search Time(25 分)
The task of this problem is simple: insert a sequence of distinct positive integers into a hash table first. Then try to find another sequence of integer keys from the table and output the average sea...原创 2018-06-14 11:37:03 · 276 阅读 · 0 评论 -
PAT—1146 Topological Order (25)
This is a problem given in the Graduate Entrance Exam in 2018: Which of the following is NOT a topological order obtained from the given directed graph? Now you are supposed to write a program to test...原创 2018-06-13 16:03:48 · 200 阅读 · 0 评论 -
PAT —1147 Heaps (30)
因为对自己不太自信,所以才报了甲级- -然后从后往前刷题,30分钟做完第一道之后,我觉得我应该报顶级的,不过无所谓了,先考着甲级吧。In computer science, a heap is a specialized tree-based data structure that satisfies the heap property: if P is a parent node of C, ...原创 2018-06-13 14:56:12 · 237 阅读 · 0 评论 -
排序碎碎念(五):数据结构基础— Sort with Swap(0, i)
这是这道题目是一个表排序的问题,也就是(cycle sort)可以去Google搜索一下,有更多的资料。可以参考一下其他的资料,比如:https://en.wikipedia.org/wiki/Cycle_sort https://www.geeksforgeeks.org/an-in-place-algorithm-for-string-transformation/你也可以看一下讲解 点击打开...原创 2018-05-14 17:16:28 · 126 阅读 · 0 评论 -
排序碎碎念(四):数据结构基础— PAT Judge
这道题我一开始是用C写的,但是自己写的用堆排序出了一点问题,我就换成了C++的sort函数,等我有空了,再去实现个完整的C语言版本吧。 - -这道题我的思路是1)结构体中不仅仅包含score[k],还要包含status[k],因为每一个题目都有四种状态,这四种状态有利于判断和输出。#define NotSubmitted -1#define CompileError 0#define Submit...原创 2018-05-14 11:14:51 · 172 阅读 · 0 评论 -
C++ 重载 [ ] , C++ 模版类的一些事项
MOOC上 很难蒙混过关的CArray3d三维数组模板类:这道题目大概是希望自己能写一个实现下面这个功能的类;CArray3D<int> a(3,4,5)a[i][j][k] = 100;然后先看一下一些参考资料:来源:http://en.cppreference.com/w/cpp/language/operatorsUser-defined classes that provid...原创 2018-05-10 13:10:29 · 523 阅读 · 0 评论 -
魔兽世界之二:装备
总时间限制: 1000ms内存限制: 65536kB描述魔兽世界的西面是红魔军的司令部,东面是蓝魔军的司令部。两个司令部之间是依次排列的若干城市。 红司令部,City 1,City 2,……,City n,蓝司令部两军的司令部都会制造武士。武士一共有 dragon 、ninja、iceman、lion、wolf 五种。每种武士都有编号、生命值这两种属性。 有的武士可以拥有武器。武器有三种,swor...原创 2018-04-19 13:17:50 · 1298 阅读 · 0 评论 -
魔兽世界之一:备战
总时间限制: 1000ms 内存限制: 65536kB描述魔兽世界的西面是红魔军的司令部,东面是蓝魔军的司令部。两个司令部之间是依次排列的若干城市。 红司令部,City 1,City 2,……,City n,蓝司令部两军的司令部都会制造武士。武士一共有 dragon 、ninja、iceman、lion、wolf 五种。每种武士都有编号、生命值、攻击力这三种属性。 双方的武士编号都是从1开始计算。...原创 2018-04-11 12:51:16 · 194 阅读 · 0 评论 -
PAT - 1144 The Missing Number(20 分) || LeetCode 41. First Missing Positive
这道题同时在PAT和LeetCode中出现哈不过PAT并没有要求用 O(1)空间复杂,可是LeetCode要求用 O(1),时间复杂度都适用O(N);1144 The Missing Number(20 分)Given N integers, you are supposed to find the smallest positive integer that is NOT in the give...原创 2018-06-14 13:19:29 · 192 阅读 · 0 评论