上一页 1 2 3 4 5 6 ··· 34 下一页
摘要: #include <iostream> void test_str(std::string &ss){ ss = "昔日旧影留心中"; } int main(){ std::string a="花开哪有不落时"; std::cout << a<< std::endl; test_str(a); st 阅读全文
posted @ 2022-02-21 08:13 方诚 阅读(43) 评论(0) 推荐(0) 编辑
摘要: 指针类型 #include <iostream> int main(){ int i = 1; int* a = &i; int *b = &i; int * c = &i; std::cout << "a="<<a << std::endl; // a=0x7ffeb29cf6ac std::co 阅读全文
posted @ 2022-02-18 07:55 方诚 阅读(39) 评论(0) 推荐(0) 编辑
摘要: #include <iostream> #include <cstring> using namespace std; void sort( char *name[], int n){ char *tmp; int i,j,k; for(i=0;i<n-1;i++){ k=i; for(j=i+1; 阅读全文
posted @ 2022-02-09 13:50 方诚 阅读(23) 评论(0) 推荐(0) 编辑
摘要: 这是C++的第一个程序,计算机的基础语言就是C/C++,未来可能会加入一个rust,但C++绝对不会消失,这是底层语言,其他的Java/Python/Php/VB...都是上层语言,其中Go也是独树一帜,另辟蹊径,但Go要想再一步,达到超过C++的高度,它还要有大突破才行,也就是说,Go现在(202 阅读全文
posted @ 2022-01-29 14:25 方诚 阅读(116) 评论(0) 推荐(0) 编辑
摘要: Rc<T>, the Reference Counted Smart Pointer Rc,多引用小指针,可以让一个地址被多个对象引用,每多一个对象,引用个数+1 In the majority of cases, ownership is clear: you know exactly which 阅读全文
posted @ 2022-01-16 13:09 方诚 阅读(37) 评论(0) 推荐(0) 编辑
摘要: Box Box是一个指针,具有固定长度, 指针在栈上,指针指向的数据在堆上, 这个复合类型是rust为用户提供的,可以实现递归调用的一个类型,它不会提升性能, 所以,除了递归,一般不用这个. The most straightforward smart pointer is a box, whose 阅读全文
posted @ 2021-12-28 12:26 方诚 阅读(311) 评论(0) 推荐(0) 编辑
摘要: fn add_one_v1 (x: u32) -> u32 { x + 1 } let add_one_v2 = |x: u32| -> u32 { x + 1 }; let add_one_v3 = |x| { x + 1 }; let add_one_v4 = |x| x + 1 ; pub f 阅读全文
posted @ 2021-11-03 13:31 方诚 阅读(42) 评论(0) 推荐(0) 编辑
摘要: 自定义的命令行参数解析 这是本人自己写的一套方法,用着感觉比较舒服,官方的参数解析请跳过此部分看后面的部分 #![allow(unused)] use std::env; extern crate mij; use mij::base::arg; fn parse_args(mut num:&mut 阅读全文
posted @ 2021-09-28 14:48 方诚 阅读(744) 评论(0) 推荐(0) 编辑
摘要: 概述 使用rust-cpython将rust程序做为python模块调用; 通常为了提高python的性能; 参考-github https://github.com/dgrunwald/rust-cpython 环境 系统:本次示例为ubantu20.04,等效于centos7 python: p 阅读全文
posted @ 2021-09-04 22:24 方诚 阅读(2224) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h>#include <stdlib.h> int main(){ int i,j,t,a[6]; printf("input 6 numbers:\n"); for(i=0;i<6;i++) scanf("%d",&a[i]); // 每一次冒泡将整个列表中最大/最 阅读全文
posted @ 2021-09-03 09:08 方诚 阅读(16) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 ··· 34 下一页