03 2020 档案
摘要:1 package main 2 3 import ( 4 "html/template" 5 "math/rand" 6 "net/http" 7 "time" 8 ) 9 10 func process(w http.ResponseWriter, r *http.Request) { 11 t
阅读全文
摘要:1 package main 2 3 import ( 4 "encoding/json" 5 "fmt" 6 "github.com/julienschmidt/httprouter" 7 "net/http" 8 ) 9 10 //ResponseWriter是一个接口 拥有三个方法 Write
阅读全文
摘要:1 #include <iostream> 2 #include <fstream> 3 4 using namespace std; 5 6 void check_cin (istream &is) 7 { 8 if(is.bad())//系统级的错误才会bad 9 { 10 cout<<"cin
阅读全文
摘要:1 #include <iostream> 2 #include <string> 3 //#include "Sales_item.h" 4 #include "Sales_item.cpp" 5 6 using namespace std; 7 //使用typedef简化定义 8 typedef
阅读全文
摘要:1 #include <iostream> 2 3 4 5 using namespace std; 6 7 //通过指针进行传递 8 void print_Values(int *x,size_t n) 9 { 10 for(size_t i=0;i!=n;i++) 11 { 12 cout<<x
阅读全文
摘要:推荐的做法是使用迭代器当做形参 1 #include <iostream> 2 #include <new> 3 #include <bitset> 4 #include <string> 5 #include <stdexcept> 6 #include <vector> 7 8 9 using
阅读全文
摘要:1 #include <iostream> 2 #include <new> 3 #include <bitset> 4 #include <string> 5 #include <stdexcept> 6 7 8 using namespace std; 9 10 11 12 //非引用形参 传递
阅读全文
摘要:1 #include <iostream> 2 #include<stdlib.h> 3 #include<string> 4 #include<vector> 5 #include<cstring> 6 #include<bitset> 7 8 9 using namespace std; 10
阅读全文
摘要:1 #include <iostream> 2 #include<stdlib.h> 3 #include<string> 4 #include<vector> 5 #include<cstring> 6 7 8 using namespace std; 9 typedef int int_arra
阅读全文
摘要:1 #include <iostream> 2 #include<stdlib.h> 3 4 5 using namespace std; 6 7 int main() 8 { 9 //创建动态数组 10 int a[10]; //静态数组 堆栈上创建的 11 int n; 12 cin>>n; 1
阅读全文
摘要:1 #include <iostream> 2 #include <string> 3 #include <vector> 4 5 6 using namespace std; 7 8 int main() 9 { 10 11 string s("hello world!"); //定义一个字符串并
阅读全文
摘要:1 #include <iostream> 2 #include <bitset> 3 #include <string> 4 5 using namespace std; 6 //bitset类型处理二进制 7 int main() 8 { 9 //bitset类型的变量a <>内的参数表示的是长
阅读全文
摘要:1 #include <iostream> 2 #include <bitset> 3 #include <string> 4 5 using namespace std; 6 //bitset类型处理二进制 7 int main() 8 { 9 //bitset类型的变量a <>内的参数表示的是长
阅读全文
摘要:1 vector<int> v(10,8); 2 vector<int>::iterator iter=v.begin(); //begin返回一个迭代器 3 4 //实质上是一个指针 5 *iter=9; 6 iter++; 7 *iter=10; 8 vector<int>::iterator
阅读全文
摘要:1 #include <iostream> 2 #include <vector> 3 4 using namespace std; 5 6 int main(){ 7 //vector容器 是一个动态数组 8 //<>里面表示的是模板参数 vector为类模板 9 vector<int> ivec
阅读全文
摘要:1 #include <iostream> 2 #include<string> 3 4 using namespace std; 27 int main(){ 28 29 //C++标准库中的string类型 30 string name("张三"); 31 cout<<name<<endl; 3
阅读全文
摘要:1 #include <iostream> 2 3 using namespace std; 4 5 int i; 6 7 int main() 8 { 9 void Bianliang(); 10 Bianliang(); 11 return 0; 12 } 13 14 #if(1) 15 voi
阅读全文
摘要:1 #include <stdio.h> 2 #include <stdlib.h> 3 #define OK 0 4 #define ERROR -1 5 6 // 7 typedef int Status; 8 typedef int ElemType; 9 10 /* 11 单链表的存储结构:
阅读全文
摘要:malloc函数: //void *malloc(unsigned int size) int *p; p=(int*)malloc(sizeof(int))//分配一个连续的内存空间,通过类型转换才能存入其他类型的变量。 函数的功能是分配一块长度为size字节的连续空间,由于不知道分配出来的空间是
阅读全文
摘要:算法的时间复杂度:用O()表示,执行次数=时间,随着输入规模n增大,T(n)增长最慢的算法为最优算法。如何计算时间复杂度:用常数1取代运行时间中的所有加法常数在修改后的运行次数函数中,只保留最高阶项如果最高阶项存在且不是1,则去除与这个项相乘的常数得到的最后结果就是O阶 int i,n=100,su
阅读全文
摘要:1 #include <stdio.h> 2 #include <stdlib.h> 3 //用指向函数的指针做函数参数 4 #if(0) 5 int main() 6 { 7 struct Student{ 8 long int num; 9 char name[20]; 10 char sex;
阅读全文
摘要:1 package main 2 3 import ( 4 "fmt" 5 ) 6 7 func main() { 8 //channel是可以让一个goroutine发送特定值到另一个goroutine的通信机制。 9 //声明通道类型 10 var a chan int //声明一个int类型的
阅读全文
摘要:内存中每一个字节都有一个编号,这个编号叫做地址。 1 scanf("%d",&a); 首先,将a的地址给scanf函数,然后函数先把a的地址保存起来,然后从键盘接收数据通过存储的a的地址保存到a变量中。 指针是存放地址的: 1 int *i_pointer; 2 i_pointer=&i; 3 //
阅读全文
摘要:开启gorouutine 1 import ( 2 "fmt" 3 "time" 4 ) 5 6 func Hello(){ 7 fmt.Println("hello") 8 } 9 10 func main() { 11 //开启goroutine需要在调用的函数前边加上go关键字即可 12 go
阅读全文
摘要:1 //学生的成绩问题 2 //定义一个5行3列的二维数组 行是存放的是哪一个人 三列分别存放三科的成绩 3 int i,j,s=0,average,v[3]; 4 int a[5][3]={{80,75,92},{61,65,71},{59,63,70},{85,87,90},{76,77,85}
阅读全文
摘要:func (接收器变量 接收器类型) 方法名(参数列表) (返回参数) { 函数体} 接收器的使用详见:http://c.biancheng.net/view/69.html
阅读全文
摘要:GO语言之指针:指针类型是一个特殊的变量,用来存储另一个变量的地址。 变量存储在内存中 如图所示a变量存储在内存中,地址为0x0001,通过&(取址符号)获得a变量的内存地址,即&a=0x0001。定义一个指针变量p,其中存储的是变量a的内存地址,如果获取变量a的具体值那么需要在指针变量p前边加*(
阅读全文
摘要:1 package main 2 3 import ( 4 "fmt" 5 "os" 6 ) 7 8 func main() { 9 filename := "./main.txt" 10 _, err := os.Stat(filename) 11 //判断文件是否存在如果不存在就创建文件 12
阅读全文
摘要:1 package main 2 3 import ( 4 "database/sql" 5 "fmt" 6 _ "github.com/go-sql-driver/mysql" 7 ) 8 9 // 定义一个全局对象db 10 var db *sql.DB 11 //定义结构体 12 type U
阅读全文
摘要:1 package main 2 3 import ( 4 "fmt" 5 "strconv" 6 ) 7 8 func main() { 9 //字符串转换成整型 10 s := "100" 11 //base指定进制(2到36),如果base为0,则会从字符串前置判断,"0x"是16进制,"0"
阅读全文
摘要:1 package main 2 3 import ( 4 "fmt" 5 "strings" 6 ) 7 8 func main() { 9 //字符串的比较是按照字典顺序进行比较 a b c d e... 10 a:="Hella" 11 b:="helle" 12 i:=strings.Com
阅读全文
摘要:相应代码: 1 package main 2 3 import ( 4 "fmt" 5 "github.com/jinzhu/gorm" 6 _ "github.com/jinzhu/gorm/dialects/mysql" 7 ) 8 9 type User struct { 10 Usernam
阅读全文

浙公网安备 33010602011771号