node

#define与typedef区别

做~自己de王妃 提交于 2020-01-28 00:35:11
1.#define 常用它来 定义常量 (包括无参量与带参量),属于 预处理 过程(编译之前),例, #define Name int ; 2.typedef 常用来 定义一个标识符及关键字的别名 ,属于 编译 过程,实际不分配内存空间,例, typedef int Name ; 3.#difine 不进行类型检查, 只是简单地字符替换 ,易出错; typedef 具有一定的封装性,不易出错; 1 #include <iostream> 2 #include <stdio.h> 3 using namespace std; 4 #define Name 3+3 5 6 int main() 7 { 8 int m; 9 int a=6; 10 m=Name*a; 11 cout<<m<<endl; 12 return 0; 13 14 } View Code 结果 m=21 ;因为: m=Name*a=3+3*6=3+18=21; 4. typedef struct Node { int x; }node1,node2; 在C中, struct Node =node1=node2 , 为结构体名; 在C++中, struct Node =Node=node1=node2 , 为结构体名; 5. struct Node { int x; }node1,node2; 在C中

(N叉树 DFS 递归 BFS) leetcode 559. Maximum Depth of N-ary Tree

╄→尐↘猪︶ㄣ 提交于 2020-01-27 20:42:30
Given a n-ary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. For example, given a 3-ary tree: We should return its max depth, which is 3. Note: The depth of the tree is at most 1000 . The total number of nodes is at most 5000 . -------------------------------------------------------------------------------------------------------------------------------------- 这个和求二叉树的最大深度类似,只要掌握了二叉树的最大深度的解法以及理解了N叉树的原理,解决这个题就会很简单了。 递归/DFS: C++代码: /* // Definition for a Node. class Node { public: int val; vector

1099 Build A Binary Search Tree (30分)

好久不见. 提交于 2020-01-27 16:38:33
A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties: The left subtree of a node contains only nodes with keys less than the node's key. The right subtree of a node contains only nodes with keys greater than or equal to the node's key. Both the left and right subtrees must also be binary search trees. Given the structure of a binary tree and a sequence of distinct integer keys, there is only one way to fill these keys into the tree so that the resulting tree satisfies the definition of a BST. You are supposed to output the level order traversal

npm安装教程(vue.js)

拜拜、爱过 提交于 2020-01-27 12:34:44
https://www.cnblogs.com/goldlong/p/8027997.html 首先理清nodejs和npm的关系: node.js是javascript的一种运行环境,是对Google V8引擎进行的封装。是一个服务器端的javascript的解释器。 包含关系,nodejs中含有npm,比如说你安装好nodejs,你打开cmd输入npm -v会发现出啊线npm的版本号,说明npm已经安装好。 引用大神的总结: 其实npm是nodejs的包管理器(package manager)。我们在Node.js上开发时,会用到很多别人已经写好的javascript代码,如果每当我们需要别人的代码时,都根据名字搜索一下,下载源码,解压,再使用,会非常麻烦。于是就出现了包管理器npm。大家把自己写好的源码上传到npm官网上,如果要用某个或某些个,直接通过npm安装就可以了,不用管那个源码在哪里。并且如果我们要使用模块A,而模块A又依赖模块B,模块B又依赖模块C和D,此时npm会根据依赖关系,把所有依赖的包都下载下来并且管理起来。试想如果这些工作全靠我们自己去完成会多么麻烦! node -v 查看 node 版本,内置包含 npm 包管理器来安装依赖包。 npm install -g typescript 一、使用之前,我们先来掌握3个东西是用来干什么的。 npm:

NEFU大一培训(排序)

安稳与你 提交于 2020-01-27 10:02:43
A(谁考了第k名-排序) ```csharp ```cpp #include <bits/stdc++.h> //简单的结构体排序 using namespace std; struct node{ //定义结构体 int xh; double cj; }s[100]; bool cmp(node x,node y) //sort用于结构体排序往往需要定义一个排序方法cmp { return x.cj>y.cj; } int main() { int n,k,i; cin>>n>>k; for(i=1;i<=n;i++) { cin>>s[i].xh>>s[i].cj; } sort(s+1,s+1+n,cmp); printf("%d %g",s[k].xh,s[k].cj); return 0; } 来源: CSDN 作者: nefu_Luxembourg 链接: https://blog.csdn.net/weixin_46105967/article/details/103928093

node开发socket.io之session 共享

删除回忆录丶 提交于 2020-01-27 08:06:54
node 服务器与 io 服务器之间的session 共享 这篇文章主要说 express4.x 版本的express-session 因为这个版本的express 本身就支持session的共享 直接上代码: app.js 如下: var express = require ( 'express' ) ; var app = express ( ) ; // socket 服务器 var http = require ( 'http' ) . Server ( app ) ; var io = require ( 'socket.io' ) ( http ) ; // session 记录用户登录状态 var session = require ( 'express-session' ) ; var sessionMiddleware = session ( { secret : "keyboard cat" , resave : false , saveUninitialized : true } ) ; io . use ( function ( socket , next ) { sessionMiddleware ( socket . request , socket . request . res , next ) ; } ) ; app . use (

(N叉树 BFS) leetcode429. N-ary Tree Level Order Traversal

孤街醉人 提交于 2020-01-27 04:43:26
Given an n-ary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). For example, given a 3-ary tree: We should return its level order traversal: [ [1], [3,2,4], [5,6] ] Note: The depth of the tree is at most 1000 . The total number of nodes is at most 5000 . ----------------------------------------------------------------------------------------------------------------------------------- 这个层序遍历,自然用BFS写。和二叉树的层序遍历类似,连代码不会相差很大。 C++代码: /* // Definition for a Node. class Node { public: int val; vector<Node*> children; Node() {} Node(int _val, vector

转载 使用npm install报错-4048 operation not permitted解决

99封情书 提交于 2020-01-27 04:11:36
npm ERR! path E:\SouthernPowerGridProject\web_project\AutoOPS\autoops\node_modules\fsevents\node_modules\dashdash\node_modules npm ERR! code EPERM npm ERR! errno -4048 npm ERR! syscall scandir npm ERR! Error: EPERM: operation not permitted, scandir 'E:\SouthernPowerGridProject\web_project\AutoOPS\autoops\node_modules\fsevents\node_modules\dashdash\node_modules' npm ERR! { Error: EPERM: operation not permitted, scandir 'E:\SouthernPowerGridProject\web_project\AutoOPS\autoops\node_modules\fsevents\node_modules\dashdash\node_modules' npm ERR! stack: 'Error: EPERM: operation not permitted, scandir

在腾讯云发布node项目(express+mysql)windows服务器

故事扮演 提交于 2020-01-27 03:28:02
首先买了服务器和域名(按照步骤来即可)后,就来到了控制台。(系统建议用2012的,2016太卡了,可以重装系统的) 在笔记本上按win+R进入cmd命令行,输入mstsc,输入公网ip,用户名、密码(这里要自己重新在腾讯云的控制台设置)。链接即可,可以在本地资源的详细设置链接笔记本的磁盘,这样在服务器里面可以找到笔记本的磁盘,实现项目的传送。 链接后进入服务器界面,然后安装之前在笔记本上配置node环境、mysql、express一样的操作,这里就不赘述了。 express项目迁移到服务器后,有些module会不见,不知道为什么,所以建议重新生成一个express项目,然后把自己的项目除了module部分的覆盖一下就好了。这时候运行项目,只能本地访问,用ip访问不了。 那是因为没有设置安全组开放端口,要设置安全组,如下,设置好。把实例(也就是服务器)加进来。 在命令行进入项目文件夹输入 node +app.js(你的主文件名)运行项目,就可以访问了(如果还不行的话,我就不知道了,当初也是不行,然后装了宝塔、iis什么的) 注意!!! app.js里的listen()这个端口一定要写成listen(80),如果出错,说node没有权限listen80,解决方案: https://www.cnblogs.com/liuzhibin/p/5653356.html//我的是刚买的服务器

ionic运行报错

混江龙づ霸主 提交于 2020-01-27 03:08:19
主要原因是因为本人升级了node的版本而项目没有更新过来就会报这个错误 需要使用命令更新项目使用 npm rebuild node-sass,然后在更新一下npm update 如果装过镜像 cnpm rebuild node-sass 更新 cnpm update同样适用 解决灵感来自 https://blog.csdn.net/moxiaoya1314/article/details/79266086 来源: CSDN 作者: 情长纸短 链接: https://blog.csdn.net/qq_39252591/article/details/103615989