position

6-1 顺序表操作集(20 分)

匿名 (未验证) 提交于 2019-12-03 00:21:02
本题要求实现顺序表的操作集。 函数接口定义: List MakeEmpty(); Position Find( List L, ElementType X ); bool Insert( List L, ElementType X, Position P ); bool Delete( List L, Position P ); 其中 List 结构定义如下: typedef int Position; typedef struct LNode *List; struct LNode { ElementType Data[MAXSIZE]; Position Last; /* 保存线性表中最后一个元素的位置 */ }; 各个操作函数的定义为: List MakeEmpty() :创建并返回一个空的线性表; Position Find( List L, ElementType X ) :返回线性表中X的位置。若找不到则返回ERROR; bool Insert( List L, ElementType X, Position P ) :将X插入在位置P并返回true。若空间已满,则打印“FULL”并返回false;如果参数P指向非法位置,则打印“ILLEGAL POSITION”并返回false; bool Delete( List L, Position P )

[LeetCode] 35. Search Insert Position

五迷三道 提交于 2019-12-03 00:15:36
二分法的模板题吧算是,给一个数字,请返回插入一个有序数组的位置。 时间O(logn) 空间O(1) 1 /** 2 * @param {number[]} nums 3 * @param {number} target 4 * @return {number} 5 */ 6 var searchInsert = function(nums, target) { 7 let left = 0; 8 let right = nums.length - 1; 9 while (left <= right) { 10 let mid = Math.floor(left + (right - left) / 2); 11 if (nums[mid] === target) { 12 return mid; 13 } else if (nums[mid] > target) { 14 right = mid - 1; 15 } else { 16 left = mid + 1; 17 } 18 } 19 return left; 20 }; 来源: https://www.cnblogs.com/aaronliu1991/p/11768696.html

RecyclerView的应用及RecyclerView的点击事件

匿名 (未验证) 提交于 2019-12-03 00:15:02
JSONArray jsonArray = jsonObject.getJSONArray("obj"); if (jsonArray.size() > 0) { for (int i = 0; i < jsonArray.size(); i++) { patientID = jb.getInteger("id"); patientPhone = jb.getString("phone"); patientSFZNum = jb.getString("identityno"); PatientPhoneBean patientPhoneBean = new PatientPhoneBean(); patientPhoneBean.setPatientID(patientID); patientPhoneBean.setPatientName(patientName); patientPhoneBean.setPatientPhone(patientPhone); patientPhoneBean.setPatientSFZNum(patientSFZNum); patientPhoneList.add(patientPhoneBean); } phoneBean.setPhoneobj(patientPhoneList); Message message = Message

数据结构课后练习题(练习一)习题1.8 二分查找 (20 分)

匿名 (未验证) 提交于 2019-12-03 00:13:02
本题要求实现二分查找算法。 函数接口定义: Position BinarySearch ( List L , ElementType X ); 其中 List 结构定义如下: typedef int Position ; typedef struct LNode * List ; struct LNode { ElementType Data [ MAXSIZE ]; Position Last ; /* 保存线性表中最后一个元素的位置 */ }; L 是用户传入的一个线性表,其中 ElementType 元素可以通过 >、 =、 <进行比较,并且题目保证传入的数据是递增有序的。函数 BinarySearch 要查找 X 在 Data 中的位置,即数组下标(注意:元素从下标1开始存储)。找到则返回下标,否则返回一个特殊的失败标记 NotFound 。 裁判测试程序样例: #include <stdio.h> #include <stdlib.h> #define MAXSIZE 10 #define NotFound 0 typedef int ElementType ; typedef int Position ; typedef struct LNode * List ; struct LNode { ElementType Data [ MAXSIZE ]; Position

元素水平垂直居中

匿名 (未验证) 提交于 2019-12-03 00:13:02
一、水平垂直居中 方法1: 当前div的宽度和高度不确定,通过绝对定位,使用 translate(-50%,-50%):元素向左和向下平移自身长宽的50% HTML 1 <div id="father"> 2 <div id="son"> 3 sssssssssssssssssssssssssssssssss 4 sssssssssssssssssssssssssssssssss 5 sssssssssssssssssssssssssssssssss 6 </div> 7 </div> CSS 1 #father{ 2 position:relative; 3 width:400px; 4 height:400px; 5 border:1px solid red; 6 } 7 #son{ 8 background:red; 9 position: absolute; 10 left:50%; 11 top:50%; 12 transform: translate(-50%, -50%); 13 } 效果图 方法2: 使用绝对定位,子div长宽确定,通过设置margin值实现居中 HTML 1 <div id="father2"> 2 <div id="son2"> 3 </div> 4 </div> CSS 1 #father2 2 { 3 position:relative; 4

线性表链表实现

匿名 (未验证) 提交于 2019-12-03 00:13:02
1 #include<bits/stdc++.h> 2 using namespace std; 3 #define sc scanf 4 #define ElemType int 5 //线性表的链式表示和实现 6 7 typedef struct LNode{ 8 int data; 9 struct LNode *next; 10 }LNode,*LinkList; 11 //关于上面为啥是这样子的,看下面链接即可 12 //https://zhidao.baidu.com/question/489369235.html 13 14 //创建链表,有n个结点 15 void CreateList(LinkList &L,int n) 16 { 17 L = (LinkList)malloc(sizeof(LNode)); 18 L->next = NULL;//创建一个带头结点的单链表 19 L->data = 0;//用于记录当前链表的元素个数 20 21 LNode *p; 22 for(int i = n;i > 0;i--) 23 { 24 p = (LinkList)malloc(sizeof(LNode));//生成新节点 25 sc("%d",&p->data); 26 p->next = L->next; 27 L->next = p; 28 } 29 }

div固定显示的几种方法

匿名 (未验证) 提交于 2019-12-03 00:09:02
很多时候我们会受到一些需求: 1、div一直置顶 2、div一直置底 3、超过一定的位置之后div置顶 4、超过一定位置之后div置底 那么下面针对上面的几个问题写几个案例: 一、div一直在屏幕的上方,这个倒是容易咱们直接使用position:fixed;然后设置他的top值和left就可以了,别忘了设置宽度哦 <div class="top"> <div class="topf">跟单</div> </div> <style> .top,.topf{ height:100px; width:100%;} .topf{ position:fixed; top:0; left:0; background:#999; text-align:center; font-size:20px; color:#fff;} </style> 点击这里查看demo -》 二、这个跟上面的例子是一样的,我不不多说了 <div class="bottom"> <div class="bottomf">跟单</div> </div> <style> .bottom,.bottomf{ height:100px; width:100%;} .bottomf{ position:fixed; bottom:0; left:0; z-index:12; background:#999; text-align

H5 plus 扫码功能实现

匿名 (未验证) 提交于 2019-12-03 00:08:02
scan . vue 界面< template > < view class = "content" > <view> 二维码数据是:{{ result }}</ view > < button class = "btn" type = "primary" @tap = "open" >自定义二维码界面</ button > </ view > </ template > <script> export default { data () { return { text : '测试' , type : 'scan-listener' , result : '' //获取到的二维码内容,根据自己需求处理结果 } }, methods : { handClick ( res ){ this . result = res ; }, open () { uni . navigateTo ({ url : './test?text=' + this . text + '&type=' + this . type , success : res => {}, fail : () => {}, complete : () => {} }); } }, onReady () { uni . $on ( 'handClick' , this . handClick ) // #ifdef APP

温故BERT之Transformer

匿名 (未验证) 提交于 2019-12-03 00:06:01
Transformer ―― attention is all you need Transformer模型是2018年5月提出的,可以替代传统RNN和CNN的一种新的架构,用来实现机器翻译,论文名称是attention is all you need。无论是RNN还是CNN,在处理NLP任务时都有缺陷。CNN是其先天的卷积操作不很适合序列化的文本,RNN是其没有并行化,很容易超出内存限制(比如50tokens长度的句子就会占据很大的内存)。 下面左图是transformer模型一个结构,分成左边Nx框框的encoder和右边Nx框框的decoder,相较于RNN+attention常见的encoder-decoder之间的attention(上边的一个橙色框),还多出encoder和decoder内部的self-attention(下边的两个橙色框)。每个attention都有multi-head特征。最后,通过position encoding加入没考虑过的位置信息。 下面从multi-head attention,self-attention, position encoding几个角度介绍。 multi-head attention:   将一个词的vector切分成h个维度,求attention相似度时每个h维度计算。由于单词映射在高维空间作为向量形式

【1.2】缓冲区和通道

匿名 (未验证) 提交于 2019-12-03 00:05:01
文章目录 一、缓冲区 (xxBuffer) 【1】简介 【2】缓冲区的基本属性 【3】缓冲区方法演示 allocate() put() flip() limit()、mark()、reset() rewind() clear() 【4】直接与非直接缓冲区 二、通道 (Channel) 【1】主要实现类 【2】获取通道 【3】通道的数据传输 一、缓冲区 (xxBuffer) 【1】简介 简介 : 一个用于指定基本数据类型的容器。由 java.nio 包定义的,所有缓冲区都是 Buffer 抽象类的子类。 作用 : 主要用于与 NIO 通道进行交互。 【2】缓冲区的基本属性 属性 定义 容量 (capacity) 表示 Buffer 最大数据容量,缓冲区容量不能为负,并且创 建后不能更改。 限制 (limit) 第一个不应该读取或写入的数据的索引,即位于 limit 后的数据 不可读写。(0 <= limit <= capacity)。 位置 (position) 下一个要读取或写入的数据的索引。缓冲区的位置不能为 负,并且不能大于其限制 标记 (mark) 重置 (reset) 标记是一个索引,通过 Buffer 中的 mark() 方法 指定 Buffer 中一个特定的 position,之后可以通过调用 reset() 方法恢复到这 个 position. 他们遵守以下不变式: