convert

PHP 文件导出(Excel, CSV,txt)

淺唱寂寞╮ 提交于 2020-04-06 11:12:23
1,Excel 导出: /* * * Excel导出例子 */ public function excel($res){ $objPHPExcel = new PHPExcel(); $objPHPExcel ->getProperties()->setCreator( " XXX " ); $objPHPExcel ->setActiveSheetIndex( 0 ); $objActSheet = $objPHPExcel-> getActiveSheet(); $objActSheet ->setCellValue( ' A1 ' , ' 门店名称 ' ); $objActSheet ->setCellValue( ' B1 ' , ' 门店UID ' ); $objActSheet ->setCellValue( ' C1 ' , ' 交易时间 ' ); $objActSheet ->setCellValue( ' D1 ' , ' 应收金额 ' ); $objActSheet ->setCellValue( ' E1 ' , ' 实收金额 ' ); $objActSheet ->setCellValue( ' F1 ' , ' 支付笔数 ' ); $objActSheet ->setCellValue( ' G1 ' , ' 取消笔数 ' ); $objActSheet

426. Convert Binary Search Tree to Sorted Doubly Linked List

断了今生、忘了曾经 提交于 2020-04-04 20:18:31
问题描述: Convert a BST to a sorted circular doubly-linked list in-place. Think of the left and right pointers as synonymous to the previous and next pointers in a doubly-linked list. Let's take the following BST as an example, it may help you understand the problem better: We want to transform this BST into a circular doubly linked list. Each node in a doubly linked list has a predecessor and successor. For a circular doubly linked list, the predecessor of the first element is the last element, and the successor of the last element is the first element. The figure below shows the circular doubly

Convert Sorted List to Binary Search Tree

陌路散爱 提交于 2020-04-04 19:48:47
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. 首先想到的是先将单链表转化为数组,就可以取中位数为根节点再递归左右子做,时间复杂度O(n),空间复杂度O(n)。 在网上搜了个时间复杂度为O(n),空间复杂度为O(1)的做法,思路如下: 由于 二叉排序树的中序遍历即有序,也就是与本题中的单链表从头到尾遍历相同 ,所以可以按照类似中序遍历的做法,首先,创建当前节点的左子,然后创建当前节点,将该节点的left指针指向之前创建好的左子,然后创建右子,以这样的顺序,每次新创建的节点都对应单链表的顺序遍历中当前位置的节点,因此,用一个全局遍历表示当链表,在递归过程中不断修改当前单链表的指针,使每次创建的节点与单链表头节点对应。代码如下: 1 public ListNode head; 2 public TreeNode sortedListToBST(ListNode head) { 3 this.head = head; 4 ListNode p = head; 5 int len = 0; 6 while (p != null) { 7 p = p.next; 8 len++; 9 } 10 return

LeetCode 426. Convert Binary Search Tree to Sorted Doubly Linked List

|▌冷眼眸甩不掉的悲伤 提交于 2020-04-04 19:47:42
看起来很难,但是仔细想一下,实质就是二叉树的中序遍历的问题,中序遍历有递归和非递归(至少两种写法)。 递归: class Solution { public: Node *prev; //实质是指向最后一个元素的指针 Node* treeToDoublyList(Node* root) { if (root==NULL) return NULL; Node *dummy=new Node(0,NULL,NULL); prev = dummy; inorder(root); prev->right = dummy->right; dummy->right->left = prev; return dummy->right; } void inorder(Node *root){ if (root==NULL) return; inorder(root->left); prev->right = root; root->left = prev; prev = root; inorder(root->right); } }; 非递归 class Solution { public: Node *prev; //实质是指向最后一个元素的指针 Node* treeToDoublyList(Node* root) { if (root==NULL) return NULL; stack

Convert Datetime to String in Sql Server

穿精又带淫゛_ 提交于 2020-03-28 21:18:05
0 Feb 22 2006 4:26PM CONVERT(CHAR(19), CURRENT_TIMESTAMP, 0) 1 02/22/06 CONVERT(CHAR(8), CURRENT_TIMESTAMP, 1) 2 06.02.22 CONVERT(CHAR(8), CURRENT_TIMESTAMP, 2) 3 22/02/06 CONVERT(CHAR(8), CURRENT_TIMESTAMP, 3) 4 22.02.06 CONVERT(CHAR(8), CURRENT_TIMESTAMP, 4) 5 22-02-06 CONVERT(CHAR(8), CURRENT_TIMESTAMP, 5) 6 22 Feb 06 CONVERT(CHAR(9), CURRENT_TIMESTAMP, 6) 7 Feb 22, 06 CONVERT(CHAR(10), CURRENT_TIMESTAMP, 7) 8 16:26:08 CONVERT(CHAR(8), CURRENT_TIMESTAMP, 8) 9 Feb 22 2006 4:26:08:020PM CONVERT(CHAR(26), CURRENT_TIMESTAMP, 9) 10 02-22-06 CONVERT(CHAR(8), CURRENT_TIMESTAMP, 10) 11 06/02/22

SQL CAST, CONVERT 比较

拈花ヽ惹草 提交于 2020-03-27 18:41:38
本文转自:http://blog.csdn.net/wobuwei/archive/2009/08/18/4458185.aspx if (@StartTime > @EndTime) Set @EndTime = cast ( convert ( char , @ScheduleDate + 1 , 101)+' '+ convert ( char , @EndTime, 108) as datetime ) Else Set @EndTime = cast ( convert ( char , @ScheduleDate , 101)+' '+ convert ( char , @EndTime, 108) as datetime ) Set @StartTime = cast ( convert ( char , @ScheduleDate , 101)+' '+ convert ( char , @StartTime, 108) as datetime ) 这条语句中的Convert,Cast 的意思,作用 Convert (data_type[,length],expression[,style]) 这个转换函数一般在时间类型和字符串类型转换的时候才用到. style格式在转换时间时候的格式如下: Style(2位表示年份) | Style(4位表示年份) |

[LintCode] 661. Convert BST to Greater Tree

南笙酒味 提交于 2020-03-23 04:47:03
Given a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus sum of all keys greater than the original key in BST. Example Example 1: Input : {5,2,13} 5 / \ 2 13 Output : {18,20,13} 18 / \ 20 13 Example 2: Input : {5,3,15} 5 / \ 3 15 Output : {20,23,15} 20 / \ 23 15 /** * Definition of TreeNode: * public class TreeNode { * public int val; * public TreeNode left, right; * public TreeNode(int val) { * this.val = val; * this.left = this.right = null; * } * } */ public class Solution { /** * @param root: the root of

Java 8 – Convert List to Map

a 夏天 提交于 2020-03-22 04:01:34
Java 8 – Convert List to Map package com.mkyong.java8 public class Hosting { private int Id; private String name; private long websites; public Hosting(int id, String name, long websites) { Id = id; this.name = name; this.websites = websites; } //getters, setters and toString() } 1. List to Map – Collectors.toMap() package com.mkyong.java8 import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.stream.Collectors; public class TestListMap { public static void main(String[] args) { List<Hosting> list = new ArrayList<>(); list.add(new Hosting(1, "liquidweb.com",

Java 8 – Convert Map to LIST

房东的猫 提交于 2020-03-22 04:01:08
Java 8 – Convert Map to LIST Few Java examples to convert a Map to a List Map<String, String> map = new HashMap<>(); // Convert all Map keys to a List List<String> result = new ArrayList(map.keySet()); // Convert all Map values to a List List<String> result2 = new ArrayList(map.values()); // Java 8, Convert all Map keys to a List List<String> result3 = map.keySet().stream() .collect(Collectors.toList()); // Java 8, Convert all Map values to a List List<String> result4 = map.values().stream() .collect(Collectors.toList()); // Java 8, seem a bit long, but you can enjoy the Stream features like

Convert Datetime to String in Sql Server

拜拜、爱过 提交于 2020-03-21 23:40:09
Convert Datetime to String in Sql Server 0 Feb 22 2006 4:26PM CONVERT(CHAR(19), CURRENT_TIMESTAMP, 0) 1 02/22/06 CONVERT(CHAR(8), CURRENT_TIMESTAMP, 1) 2 06.02.22 CONVERT(CHAR(8), CURRENT_TIMESTAMP, 2) 3 22/02/06 CONVERT(CHAR(8), CURRENT_TIMESTAMP, 3) 4 22.02.06 CONVERT(CHAR(8), CURRENT_TIMESTAMP, 4) 5 22-02-06 CONVERT(CHAR(8), CURRENT_TIMESTAMP, 5) 6 22 Feb 06 CONVERT(CHAR(9), CURRENT_TIMESTAMP, 6) 7 Feb 22, 06 CONVERT(CHAR(10), CURRENT_TIMESTAMP, 7) 8 16:26:08 CONVERT(CHAR(8), CURRENT_TIMESTAMP, 8) 9 Feb 22 2006 4:26:08:020PM CONVERT(CHAR(26), CURRENT_TIMESTAMP, 9) 10 02-22-06 CONVERT(CHAR(8