排序
【C】宏定义拓展
唉,还是要拓展一下宏定义,不能只知道#define PI 3.14乐。 第一个例子,'##' #include <stdio.h> #define f(g,g2) g##g2 int main(){ int var12=100; printf('%d',f(var,12)); return 0; } ...
【C】顺序数组的二分查找
关键函数 int binarySearch(int arr[],int n,int k){ int low=0,mid,high=n-1; while(low<=high){ mid = (low + high)/2; if (k==arr[mid]){ return mid; } if (k<arr[mid]){ high = mid ...
【C】在文件中定位
要实现在C语言中打开文件后对文件定位,需要学习两个函数: rewind和fseek。 rewind函数用于将当前文件指针的位置定位到文件头。 用法:rewind(fp); fseek函数用于将当前位置指针移动到距离第三...
【C】合并有序数组
#include <stdio.h> int main(){ int M,N; int a[]={1,3,5,6,8},b[]={1,2,5,7,8,9}; M=sizeof(a)/sizeof(a[0]); N=sizeof(b)/sizeof(b[0]); int c[M+N]; int i=0,j=0,k=0; //当有任何一个数...
【NOIP2012 普及组】质因数分解
题目描述 已知正整数 n 是两个不同的质数的乘积,试求出两者中较大的那个质数。 输入格式 输入一个正整数 n。 输出格式 输出一个正整数 p,即较大的那个质数。 样例 #1 样例输入 #1 21 样例输出...
【C】if-else if-else和switch-case
if-else if-else #include<stdio.h> int main() { int type=0; scanf('%d',&type); if (type==1) printf('早'); else if (type==2) printf('中'); else if (type==3) printf('晚'); else...
【C++】使用cpp-httplib库实现http通讯
下载 GitHub:https://github.com/yhirose/cpp-httplib 仅需下载头文件httplib.h后导入至项目中即可,非常简单 服务端 现在以我的个人通讯录管理系统项目中的云端备份功能为例,简单的讲解这个...
【深基2.例12】上学迟到
题目描述 学校和 yyy 的家之间的距离为 s 米,而 yyy 以 v 米每分钟的速度匀速走向学校。 在上学的路上,yyy 还要额外花费 10 分钟的时间进行垃圾分类。 学校要求必须在上午 8:00 到达,请计算...
【模拟】旋转矩阵
#include<stdio.h> int main(){ int n; scanf('%d',&n); int a[n][n]; int top=0,down=n-1,left=0,right=n-1,count=1; while(count<=n*n){ for (int i=left;i<=right;i++){ a[top]...
【C++】cpp-httplib研究链接
https://github.com/yhirose/cpp-httplib https://blog.csdn.net/qq_40344790/article/details/135246178 https://juejin.cn/post/7169574207632703519 https://www.bilibili.com/video/BV1Xt4y...
【C】交换,交换,交换!(指针&函数)
代码 #include<stdio.h> void swap(int *x,int *y){ int t; t=*x; *x=*y; *y=t; } int main(){ int a,b,*pa,*pb; pa=&a;pb=&b; scanf('%d %d',&a,&b); swap(pa,pb); printf('%d %d',...
【C】使用函数递归实现二分查找数组最大值
#include <stdio.h> //二分查找最大值 int Max(int r[],int low,int high){ int mid,maxL,maxR; if (low==high){ return r[low]; } else{ mid=(high+low)/2; maxL=Max(r,low,mid); maxR=Max(...