- 博客(7)
- 资源 (3)
- 收藏
- 关注
原创 编写基于gRPC的C/S通信模型
1、编写.proto文件包含:1)定义service,用service{}包起来service ServiceName{ rpc funcname1(Request) returns (Reponse){} rpc funcname2(Request) returns (Reponse){}}2)message Request{}3)message Response{}2、...
2018-06-22 20:13:28 905
原创 web-app开发——简单的HTTP服务器
go本身可以直接实现HTTP服务器,而不依赖于nginx、Apache等服务器,直接使用包net/http中的函数即可实现,代码如下:package mainimport ( "fmt" "log" "net/http")func helloWorld(w http.ResponseWriter, r *http.Request) { r.ParseForm() //解析参数,默...
2018-06-19 14:51:05 954
原创 Go语言——struct、type、func的综合用法
最近在学golang语言,对于struct、type、func的学习进行了简单的编程练习,代码如下package mainimport ( "fmt")const ( WHITE = iota BLACK BLUE RED YELLOW)//Color 声明Color为byte的别名type Color byte //Box type boxtype Box s...
2018-06-15 19:48:08 10119
原创 Set Matrix Zeroes
需求:Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in-place.Example 1:Input: [ [1,1,1], [1,0,1], [1,1,1]]Output: [ [1,0,1], [0,0,0], [1,0,1]]分析:1、...
2018-06-08 10:15:02 170
原创 jump games I/II
需求I:Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Determine if yo...
2018-06-07 17:13:27 161
原创 Spiral Matrix I/II
需求:Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.Example 1:Input:[ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ]]Output: [1,2,3,6,9,8,7,4,5]分析:...
2018-06-07 14:26:07 159
原创 N-Queens I/II
需求:n皇后问题,有一个n*n的棋盘,有n个皇后,要保证每个皇后不能在同一行、同一列、同一对角线,这样才不会出现冲突,求解n皇后共有多少种放置方式。分析:1、创建n*n的char型二维数组,初始化为'.',表示没有放置皇后。2、因为皇后不能在同一行,所以将皇后i放到行i,逐行确定每个皇后的位置。假设,现在要确定皇后num(num的范围是0~n-1)的位置,如果num==n,那么说明已经找到了一个可...
2018-06-07 10:30:27 459
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人