include

Linux编程------线程api

萝らか妹 提交于 2020-03-08 20:24:33
通用的头文件 # include <stdio.h> # include <stdlib.h> # include <string.h> # include <pthread.h> # include <unistd.h> //系统调用错误 # define err_sys(msg) do{\ perror(msg);\ exit(1);}while(0) //非系统调用导致的致命错误 # define err_exit(msg) do{\ fprintf(stderr, msg);\ exit(1);}while(0) tid的一种实现是指向线程结构的指针 /* 判断是否是同一个线程 */ int pthread_equal ( tid1 , tid2 ) /* 获取当前线程id */ pthread_t pthread_self ( ) ; /* 创建线程 */ int pthread_create ( & tid , attr , func , arg ) ; // return 0 on sucess void * ( * func ) ( void * ) ; //=> func = hello; void * hello ( void * a ) { return ( void * ) 0 ; } /* 线程主动退出 */ //rval为返回值,可以为NULL void

实验3 循环语句

浪尽此生 提交于 2020-03-08 18:26:01
实验结论 Part2: 补足程序,使程序符合题目要求并正确运行 编程找出5个整数中的最大数和最小数,并输出找出的最大数和最小数。 完整代码如下: #include <stdio.h> #include <stdlib.h> int main() { int number, max, min, n; n=1; printf("输入第%d个数: ", n); scanf("%d", &number); max = number; min = number; while(n<5) { n++; printf("输入第%d个数: ", n); scanf("%d", &number); if(number>max) max = number; else if(number<min) min = number; } printf("最大数为: %d\n", max); printf("最小数为: %d\n", min); system("pause"); return 0; } 运行结果如下: Part3: 编程练习 编程输出101-200之间所有素数,并输出这一区间内素数个数。 完整代码如下: //编程输出101-200之间所有素数,并输出这一区间内素数个数。 #include <stdio.h> #include <math.h> int isprime(int n); int main

docker环境中安装gd扩展

家住魔仙堡 提交于 2020-03-08 18:11:26
方案1 一般情况下可能会想到安装命令 docker-php-ext-install gd 但是很有可能出现错误 configure: error: png.h not found. 因为可能本身没有安装png等处理库 方案2 #更新安装依赖资源库 apt update #安装基础库 apt install -y libwebp-dev libjpeg-dev libpng-dev libfreetype6-dev #设置配置文件 docker-php-ext-configure gd --with-webp-dir=/usr/include/webp --with-jpeg-dir=/usr/include --with-png-dir=/usr/include --with-freetype-dir=/usr/include/freetype2 #安装扩展 docker-php-ext-install gd #使扩展可用 docker-php-ext-enable gd 安装过程中如果出现了以下错误,可能是apt的源设置的不正确 可以在/etc/apt/source.list中设置中科大的源再尝试上面的操作 deb http://mirrors.ustc.edu.cn/debian stable main contrib non-free deb-src http:/

C/C++库函数

≯℡__Kan透↙ 提交于 2020-03-08 17:59:33
C/C++库函数-2020-3-8 函数名 函数模型 功能 返回值 头文件 abs int abs(int x) 求整数x的绝对值 计算结果 #include <stdlib.h> 或 #include <cstdlib> fabs double fabs(double x) 求x的绝对值 计算结果 #include <math.h> islower int islower(int ch) 检查ch是否小写字母 是,返回1,否,返回0 #include <ctype.h> 或 #include<cctype cos double cos(double x) 计算cos(x) 计算结果 #include <math.h> pow double pow(double x,double y) 计算x y 的值 计算结果 #include <math.h> rand int rand(void) 产生随机数 随机整数 #include <stdlib.h> 或 #include <cstdlib> toupper int toupper(int ch) 将ch字符转换成大写字母 与ch相应的大写字母 #include <ctype.h> 或 #include<cctype strlen unsigned int strlen(char *str) 统计字符串str中字符个数 返回字符个数

zabbix中文乱码的问题

泄露秘密 提交于 2020-03-08 17:41:18
在使用zabbix时,有时候会出现中文乱码的问题,如下: 因为zabbix自身对中文简体的支持不完善,需要我们手动的去上传新的字体进行替换: 1、在windows获取字体库文件 在Windows上的字体库中选择一个字体文件上传到zabbix的字体库中。 在C:\Windows\Fonts中复制想要的字体,后缀为ttf,若本身问大写,请改成小写的文件后缀ttf,并上传至zabbix服务器的fonts目录中 [root@manage fonts]# find / -name "fonts" /usr/share/X11/fonts /etc/fonts /data/java/jre/lib/fonts /data/webapps/css/google-fonts/roboto/fonts /data/webapps/css/font-awesome/fonts /data/webapps/css/icomoon/fonts /data/webapps/scripts/yui/fonts /var/www/html/zabbix/fonts ##上传字体目录 2、替换旧字体文件 [root@manage fonts]# find / -name "defines.inc.php" /usr/share/zabbix/include/defines.inc.php /tmp/zabbix

纪念char n反向冲分

被刻印的时光 ゝ 提交于 2020-03-08 12:47:42
cf 1322A # include <cstdio> # include <cstdlib> # include <cstring> # include <cmath> # include <iostream> # include <iomanip> # include <string> # include <algorithm> # include <stack> # include <queue> # include <set> # include <vector> # include <map> # define INF 0x3f3f3f3f # define LINF 0x3f3f3f3f3f3f3f3f # define ll long long # define ull unsigned long long # define uint unsigned int # define l(x) ((x)<<1) # define r(x) ((x)<<1|1) # define lowbit(x) ((x)&(-(x))) # define ms(a,b) memset(a,b,sizeof(a)) # define NSYNC std::ios::sync_with_stdio(false);std::cin.tie(0);std::cout.tie(0); using

数据--第47课 - 查找的概念

本秂侑毒 提交于 2020-03-08 11:22:29
第47课 - 查找的概念 1. 查找的定义 (1) 查找表是由同一类型的数据元素构成的集合。 (2) 查找是根据给定的某个值,在查找表中确定一个其关键字等于给定值的数据元素。 注意: l 从逻辑意义上来说,查找表中的数据元素之间没有本质的关系。 l 查找表可以不是线性表,树结束和图结构的任意一种。 2. 查找的概念 (1)查找的操作 静态查找: 查询某个特定的数据元素是否在查找表中。 检索某个特定的数据元素的各种属性。 动态查找: 在查找中插入一个数据元素。 从查找表中删去某个数据元素。 (2)查找表中的关键字 数据元素中某个数据项的值,用以标识一个数据元素。 主关键字:可以唯一的标识一个数据元素的关键字。 次关键字:可以识别不止一个数据元素的关键字。 (3)查找的结果 查找成功: 找到满足条件的数据元素,作为结果,可返回数据元素在查找表中的位置,也可以返回该数据元素的具体信息。 查找失败: 无法找到满足条件的数据元素,作为结果,应该报告一些错误信息,如失败标志、失败位置。 3. 程序--静态查找和动态查找 #include <stdio.h> #include <stdlib.h> #include <time.h> #include "SeqList.h" #define SIZE 20 /* run this program using the console pauser

归并排序的应用

痴心易碎 提交于 2020-03-08 10:44:13
先将其排序,后进行比赛会发现,赢得还是按分手从大到小, 输得也是,固然可以想到归并排序,将两个有序的数组和并。 归并排序参考: https://www.cnblogs.com/rstz/p/12393223.html 1 #include <iostream> 2 #include <algorithm> 3 #include <string> 4 #include <vector> 5 using namespace std; 6 constexpr size_t maxn = 2e5 + 5; 7 struct node{ 8 int s, idx, w; 9 bool operator <(const node &t)const{//运算符重载 10 if(t.s != s) 11 return s > t.s; 12 return idx < t.idx; 13 } 14 15 }; 16 node p[maxn], winer[maxn], loser[maxn]; 17 int main(){ 18 int n, r, q; 19 cin >> n >> r >> q; 20 for(int i = 1; i <= 2 * n; ++ i) { 21 cin >> p[i].s; 22 p[i].idx = i; 23 } 24 for(int i = 1; i <=

[蓝桥杯2016初赛]密码脱落

℡╲_俬逩灬. 提交于 2020-03-08 10:39:33
密码脱落 问题描述 题目描述 X星球的考古学家发现了一批古代留下来的密码。这些密码是由A、B、C、D 四种植物的种子串成的序列。 仔细分析发现,这些密码串当初应该是前后对称的(也就是我们说的镜像串)。 由于年代久远,其中许多种子脱落了,因而可能会失去镜像的特征。 你的任务是:给定一个现在看到的密码串,计算一下从当初的状态,它要至少脱落多少个种子,才可能会变成现在的样子。 输入 输入存在多组测试数据,对于每组测试数据输入一行,表示现在看到的密码串(长度不大于1000) 输出 对于每组测试数据要求输出一个正整数,表示至少脱落了多少个种子。 样例输入 ABCBA ABDCDCBABC 样例输出 0 3 分析 题目中要求我们去找脱落的种子。 首先我们要想一下: 1、种子在脱了几个我不知道; 2、种子脱在哪里我不知道。 这两个办法是没法解决的。 这时候我们就要反着想一下,我们是否可以去找没有脱落的种子,即找相同。 那么问题有来了:相同怎么找。 根据回文串的特性(左边和右边对称), 思路一:找到对称轴,左边和右边对比。 种子脱落之后,对称轴的位置也变得扑朔迷离。所以放弃(扑街)。 思路二:把原串倒过来构造另一个串。去找两串中相同的子串。(√) 找相同子串要用到dp[][]; i j 表示 str1前i个种子与str2前j个种子相同种子数; 当str1[i]=str2[j]相等时

蚂蚁感冒 蓝桥 (模拟)

∥☆過路亽.° 提交于 2020-03-08 04:06:41
试题 历届试题 蚂蚁感冒 资源限制 时间限制:1.0s 内存限制:256.0MB 问题描述   长100厘米的细长直杆子上有n只蚂蚁。它们的头有的朝左,有的朝右。 每只蚂蚁都只能沿着杆子向前爬,速度是1厘米/秒。 当两只蚂蚁碰面时,它们会同时掉头往相反的方向爬行。 这些蚂蚁中,有1只蚂蚁感冒了。并且在和其它蚂蚁碰面时,会把感冒传染给碰到的蚂蚁。 请你计算,当所有蚂蚁都爬离杆子时,有多少只蚂蚁患上了感冒。 输入格式   第一行输入一个整数n (1 < n < 50), 表示蚂蚁的总数。 接着的一行是n个用空格分开的整数 Xi (-100 < Xi < 100), Xi的绝对值,表示蚂蚁离开杆子左边端点的距离。正值表示头朝右,负值表示头朝左,数据中不会出现0值,也不会出现两只蚂蚁占用同一位置。其中,第一个数据代表的蚂蚁感冒了。 输出格式   要求输出1个整数,表示最后感冒蚂蚁的数目。 样例输入 3 5 -2 8 样例输出 1 样例输入 5 -10 8 -20 12 25 样例输出 3 模拟就好 # pragma warning(disable:4996) # include "iostream" # include "functional" # include "algorithm" # include "cstring" # include "stack" # include