摘要:
#include #include using namespace std; class Operation { protected: double numberA; double numberB; public: double getA() { return numberA; } double getB() { return numberB; } void s... 阅读全文
摘要:
//把每个值,插入到适合他的位置。插入的方法是:它前面的值往后移动。这个算法需要下标为0的位置作为哨兵#include void InsertSort(int *L) { int i, j; for (i = 2; i L[0]; j--) { L[j + 1] = L[j]; } L[j + 1] = L[0]; //因为循环最后的j--了 } }... 阅读全文
摘要:
//记住适合位置i的下标,把它换过来#include void swap(int *a, int* b) { int tmp = 0; tmp = *a; *a = *b; *b = tmp; } //比较次数n(n-1)/2,交换次数n-1,时间复杂度为O(n2),但是比冒泡的效率高。因为冒泡的比较和交换次数之和是n(n-1) void SelectSort(int *L) { ... 阅读全文
摘要:
#!/bin/bash #2.sh #编写shell脚本获取本机的网络地址。 #比如:本机的ip地址是:192.168.100.2/255.255.255.0,那么它的网络地址是192.168.100.1/255.255.255.0 #注意:Bcast与前面的Ip地址之间是两个空格,所以一定要把两个空格都删掉#grep后面的搜索词加不加引号都可以,如果是一个比较长,有空格的,比如inet add... 阅读全文