C/C++
lhj_sjtu
爱科研,爱技术,爱生活的工科女,但也是萌妹子!!!
展开
-
牛客网中c++题目及其知识点详解
1.下面描述正确的是12int*p1 = newint[10]; int*p2 = newint[10]();p1和p2申请的空间里面的值都是随机值p1和p2申请的空间里的值都已经初始化p1申请的空间里的值是随机值,p2申请的空间里的值已经原创 2017-06-17 14:58:04 · 1516 阅读 · 0 评论 -
struct和class有什么区别
C的struct与C++的class的区别:struct只是作为一种复杂数据类型定义,不能用于面向对象编程。 C++中的struct和class的区别:对于成员访问权限以及继承方式,class中默认的是private的,而struct中则是public的。class还可以用于表示模板类型,struct则不行。...原创 2018-03-12 12:02:36 · 524 阅读 · 0 评论 -
C++之面向对象的体现在哪里
面试的时候可能会经常遇到这个问题,面试官想听到的答案应该是C++面向对象的三大特性是:封装,继承,多态 这里可以参考https://www.cnblogs.com/iloverain/archive/2016/08/05/5726752.html封装 就是把客观事物封装成抽象的类继承 是指可以让某个类型的对象获得另一个类型的对象的属性的方法多态 就是向不同对象发生同一个消原创 2018-01-17 12:24:13 · 924 阅读 · 0 评论 -
冒泡排序--C++实现
int Bubble_Partition(int arr[],int low,int high){ for(int i=low;i<high;i++) {if (arr[i]>=arr[i+1]) swap(arr[i],arr[i+1]); } return high-1;}void BubbleSort(int arr[],int low,int high){i原创 2018-01-17 12:14:10 · 194 阅读 · 0 评论 -
(排序算法总结)快速排序c++实现--将未排序部分的最后一个数作为主元
#include using namespace std;int Partition(int arr[],int low,int high){ int x=arr[high]; int mid=low-1; for(int i=low;i<high;i++) { if(arr[i]<x) {mid++; swap(arr[i],arr[mid]);原创 2018-01-16 19:34:20 · 500 阅读 · 0 评论 -
Hackranker题目1__输入流_getchar
#include #include #include using namespace std;int main() { int i = 4; double d = 4.0; string s = "HackerRank ";// Declare second integer, double, and String variables. // Declare s原创 2018-01-16 13:35:17 · 451 阅读 · 0 评论 -
数据结构学习笔记7--c语言建立一个链表(已测正确无误)
#include #include typedef struct linknode{ int data; struct linknode *next;//struct linknode是一个结构体类型名,需要作为整理而使用}node;// typed struct A B;表示为结构体struct A起一个别名 B. 那么在后面创建一个变量x的时候可以用struct A x;或者B原创 2017-10-12 15:06:24 · 418 阅读 · 0 评论 -
结构体定义:struct与typedef struct 用法详解和用法小结
转载自:http://blog.csdn.net/haiou0/article/details/6877718一、typedef的用法在C/C++语言中,typedef常用来定义一个标识符及关键字的别名,它是语言编译过程的一部分,但它并不实际分配内存空间,实例像: typedef int INT; typedef int ARRAY[10]; typedef (int*) pINT; ty转载 2017-10-12 14:46:52 · 342 阅读 · 0 评论 -
leetcode--476--Number Complement(我的解法)
原题目为:我的源代码如下:class Solution{public: int findComplement(int num) {vectorarrayx(31); for(int i=0;i<31;i++) arrayx[i]=0; int numx=0; while (1) { arrayx[numx]=num%2;原创 2017-06-18 22:26:50 · 230 阅读 · 0 评论 -
leetcode--Hamming Distance _我的解法
原题目:我的解法:class Solution {public: int hammingDistance(int x, int y){ vectorarrayx(31),arrayy(31); for(int i=0;i<31;i++) {arrayx[i]=0; arrayy[i]=0; } int nu原创 2017-06-18 17:33:04 · 285 阅读 · 0 评论 -
c++指针加1
int64_t *p2; char *p1; p1=(char*)0x800000; p2=(int64_t*)0x800000; char*a=p1+2; int64_t*b=p2+2;那么a和b的值分别是:0x800002和0x800010因为设指针p的类型为T,则p+i=(p的值)+i*sizeof(T)的字节数char是1个字节,int64_t是8个字节。p1+2=(p1中存...原创 2018-03-27 13:38:49 · 5554 阅读 · 0 评论