【iOS】Touch Drag Inside 和 Touch Drag Outside、Touch Drag Enter、Touch Drag Exit的区别

Touch Drag Inside:手指在控件窗口内拖动

Touch Drag Outside:手指在控件窗口外拖动

Touch Drag Enter:手指从控件窗口外部拖动到内部

Touch Drag Exit:手指从控件窗口内部拖动到外部


[依据] 来自Apple官方文档 UIControlEvents

UIControlEventTouchDragInside:An event where a finger is dragged inside the bounds of the control.

UIControlEventTouchDragOutside:An event where a finger is dragged just outside the bounds of the control.

UIControlEventTouchDragEnter:An event where a finger is dragged into the bounds of the control.

UIControlEventTouchDragExit:An event where a finger is dragged from within a control to outside its bounds.

【iOS】Touch Up Inside 和 Touch Up Outside 的区别

Touch Up Inside:按下按钮,并且在按钮内部(inside)松手

Touch Up Outside:按下按钮,并且在按钮外部(outside)松手


[依据] 来自Apple官方文档 UIControlEvents

UIControlEventTouchUpInside:A touch-up event in the control where the finger is inside the bounds of the control.

UIControlEventTouchUpOutside:A touch-up event in the control where the finger is outside the bounds of the control.

【note】编程范式(编程范型)的含义和种类,多范式编程语言

范型 / 范式 = 模式、方法
编程范式 / 编程范型 = 编程的模式、风格

编程范式主要包括:结构化编程、面向对象编程、过程式(程序式)编程、函数式编程(泛函编程)、指令式(命令式)编程、泛型编程、面向切面(面向侧面)编程

不同的编程语言会提倡不同的“编程范型”,一些语言是专门为某个特定的范型设计的(如Java是较纯粹的面向对象编程语言,C语言是过程式编程语言),而另一些语言支持多种范型(如C++、Python、Ruby、Swift),这种支持多种范型的编程语言就叫做多范式编程语言

常见的多范式编程语言:
C++:面向对象编程、程序式编程、泛型编程
Python:面向对象编程、指令式编程、函数式编程、程序式编程、面向切面编程
Ruby:面向对象编程、命令式编程、函数式编程
Swift:面向对象编程、函数式编程、指令式编程

PAT 1154 Vertex Coloring (25 分)-甲级

A proper vertex coloring is a labeling of the graph’s vertices with colors such that no two vertices sharing the same edge have the same color. A coloring using at most k colors is called a (proper) k-coloring.

Now you are supposed to tell if a given coloring is a proper k-coloring.

Input Specification:
Each input file contains one test case. For each case, the first line gives two positive integers N and M (both no more than 10​4), being the total numbers of vertices and edges, respectively. Then M lines follow, each describes an edge by giving the indices (from 0 to N−1) of the two ends of the edge.

After the graph, a positive integer K (≤ 100) is given, which is the number of colorings you are supposed to check. Then K lines follow, each contains N colors which are represented by non-negative integers in the range of int. The i-th color is the color of the i-th vertex.

Output Specification:
For each coloring, print in a line k-coloring if it is a proper k-coloring for some positive k, or No if not.

Sample Input:
10 11
8 7
6 8
4 5
8 4
8 1
1 2
1 4
9 8
9 1
1 0
2 4
4
0 1 0 1 4 1 0 1 3 0
0 1 0 1 4 1 0 1 0 0
8 1 0 1 4 1 0 5 3 0
1 2 3 4 5 6 7 8 8 9
Sample Output:
4-coloring
No
6-coloring
No

题目大意:给出一个图(先给出所有边,后给出每个点的颜色),问是否满足:所有的边的两个点的颜色不相同
分析:把所有边存起来,把所有点的颜色存起来(存的过程中放入set统计颜色个数),枚举所有边,检查是否每条边的两点个颜色是否相同,若全不相同,则输出颜色个数,否则输出No~

 

Swift语言代码格式规范样例

代码来源于:《The Swift Programming Language Swift 4.2》

for循环 | if语句 | switch语句

函数 | 闭包

枚举 | 结构体

错误处理

泛型