php输出echo、print、print_r、printf、sprintf、var_dump的区别比较

摘要: 一、echo echo() 实际上不是一个函数,是php语句,因此您无需对其使用括号。不过,如果您希望向 echo() 传递一个以上的参数,那么使用括号会发生解析错误。而且echo是返回void的,并不返回值,所以不能使用它来赋值。例子: 复制代码代码如下: <?php $a = echo("55n 阅读全文
posted @ 2018-11-24 15:16 那年月光 阅读(588) 评论(0) 推荐(0) 编辑

Linux系统下打印第n行的方法

摘要: 方法一:cat cat filename | head -n 5 | tail -n +5 方法二:sed sed -n '5p' filename 扩展:打印第3~5行 cat filename | head -n 5 | tail -n +3 sed -n '3p;4p;5p' filename 阅读全文
posted @ 2018-10-22 00:40 那年月光 阅读(4487) 评论(0) 推荐(0) 编辑

Linux系统下python代码运行shell命令的方法

摘要: 方法一:os.popen 方法二:os.system 其中trans.sh代码: 方法三:subprocess 方法四:commands 阅读全文
posted @ 2018-10-20 22:11 那年月光 阅读(3739) 评论(0) 推荐(0) 编辑

fun(int **p)的使用

摘要: #include <iostream>using namespace std;void fun(int **p){ cout << p[0][0] << endl;}void main(){ int a[] = {1,2,3,4,5}; int *p = a; int **q = &p; fun(q 阅读全文
posted @ 2017-09-02 18:40 那年月光 阅读(677) 评论(0) 推荐(0) 编辑

快速排序法(挖坑+分治)

摘要: #include<iostream>using namespace std; int adjustArray(int s[], int l, int r){ int i = l, j = r, x = s[i]; while (i<j) { while (i < j&&s[j] >= x) j--; 阅读全文
posted @ 2017-08-30 01:15 那年月光 阅读(484) 评论(0) 推荐(0) 编辑

不引用第三方变量交换a和b的值

摘要: 方法一:(可操作字符) a = a^b; b = a^b; a = a^b; 方法二:(可操作字符) a=a+b; b=a-b; a=a-b; 方法三:(不可以操作字符) a=a*b; b=a/b; a=a/b; 方法四: swap(a,b); 阅读全文
posted @ 2017-08-29 23:56 那年月光 阅读(1615) 评论(0) 推荐(0) 编辑

判断n是否为质数

摘要: #include #include #include using namespace std; int main() { bool judg = true; int i; while (cin >> i) { if (i < 1) { cout << "请输入1以上的值" << endl; ... 阅读全文
posted @ 2017-08-27 17:51 那年月光 阅读(595) 评论(0) 推荐(0) 编辑

第n个质数

摘要: //注:for循环之后第三个式子总会操作一遍。#include using namespace std; int main() { int n; while (cin >> n) { if (n == 1) { cout << 1 << endl; } else if (n == 2) { cout << 3 << endl; } else ... 阅读全文
posted @ 2017-08-19 17:42 那年月光 阅读(444) 评论(0) 推荐(0) 编辑

c 最简单的链表

摘要: #include struct node { int data; struct node *next; //指向本身的指针 }; // main() { struct node a,b,c,*h,*p;//定义结构体和结构体指针 a.data=10; //设置结构体变量的值 b.data=20; c.data=30; h=&a; //设置结构体指针的指向 a.next=... 阅读全文
posted @ 2017-08-03 12:01 那年月光 阅读(181) 评论(0) 推荐(0) 编辑

vim操作

摘要: 1.批量注释与取消注释 使用下面命令在指定的行首添加注释::起始行号,结束行号s/^/注释符/g取消注释::起始行号,结束行号s/^注释符//g例子:在10 - 20行添加 // 注释:10,50s#^#//#g在10 - 20行删除 // 注释:10,20s#^//##g 2.批量替换(将所有的空 阅读全文
posted @ 2017-07-24 20:26 那年月光 阅读(162) 评论(0) 推荐(0) 编辑