当前位置: 首页 > news >正文

腾讯云服务器做网站wordpress 分类 php

腾讯云服务器做网站,wordpress 分类 php,企业简介介绍,wordpress 主题 排行榜三&#xff1a;插入排序&#xff08;原地插入排序&#xff09;O(N^2) 找到位置&#xff0c;用此位置的值与其前面位置的值比较&#xff0c;直到找到合适的位置 for(i0;i<len;i) //要插入的数据{t a[i];//非原地插入排序可不用t记录位置的值j i; while(j>0 && …

三:插入排序(原地插入排序)O(N^2)

找到位置,用此位置的值与其前面位置的值比较,直到找到合适的位置

	for(i=0;i<len;i++) //要插入的数据{t = a[i];//非原地插入排序可不用t记录位置的值j = i; while(j>0 && a[j-1] > t)//寻找合适的插入位置{a[j] = a[j-1];j--;}a[j] = t;}

四:二分查找

	int n;scanf("%d",&n);int begin = a[0];int end = a[len-1];while(begin <= end){int mid = (begin + end)/2;if(a[mid] > n){end = mid - 1;}else if(a[mid] < n){begin = mid + 1;}else{break;}}int mid = (begin + end)/2;if(begin <= end){printf("found,located in a[%d]\n",mid);}else{printf("not found\n");}

八:字符型的一维数组

一:

主要用途:存放字符串数据 结束标志 // ‘\0’

​ 字符串都是按照字符数组的方式存储 //“hello”---->0 1 2 3 4 5,占六个内存空间,剩下部分补零

	char s[10] = "hello";int i = 0;while(s[i] != 0){printf("%c",s[i]);++i;}putchar('\n');

二:数组大小识别

​ 字符串中 ‘\0’ 也是占空间

	char s1[] = {'h','e','l','l','o'};char s2[10] = "hello";char s3[] = "hello";printf("sizeof(s1) = %ld\n",sizeof(s1));printf("sizeof(s2) = %ld\n",sizeof(s2));printf("sizeof(s3) = %ld\n",sizeof(s3));
结果:sizeof(s1) = 5sizeof(s2) = 10sizeof(s3) = 6

三:字符串操作函数gets/puts

scanf("%s",s); gets/puts

char *gets(char *s); 参数:s代表存放字符串的一块空间的地址 返回值:s

	char s[20] ={1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};gets(s);//可能导致缓冲区溢出,使栈int i = 0;while(s[i] !='\0'){printf("%c",s[i]);++i;}putchar('\n');

int puts(const char *s); 参数:s 要输出的字符 返回值:成功返回非负 失败返回-1

​ 输出自带换行

	gets(s);puts(s);

四:strlen //计算字符串长度

字符串长度:‘\0’ 前面字符的个数(不包括\0)

	char s[20];scanf("%s",s);int i = 0;int count = 0;while(s[i] != '\0'){count++;i++;}printf("long = %d\n",count);

size_t strlen(const char *s); //参数:s要统计的字符串 返回值:返回字符串的长度值

#include<stdio.h>
#include<string.h>int main(int argc, const char *argv[])
{char s[20];gets(s);printf("long = %ld\n",strlen(s));return 0;
}

五:strcpy字符串复制

	char s1[] = "hello";char s2[20];int i = 0;while(s1[i] != '\0'){s2[i] = s1[i];i++;}s2[i] = '\0';//保证复制后的字符串有效puts(s1);puts(s2);

char *strcpy(char *dest, const char *src);

​ //参数 @src 要复制的字符 @dest要复制到的目标 返回值:成功返回dest 失败返回NULL

#include<stdio.h>
#include<string.h>int main(int argc, const char *argv[])
{char s1[] = "hello";char s2[20];strcpy(s2,s1);puts(s1);puts(s2);return 0;
}

六:

http://www.dtcms.com/a/575042.html

相关文章:

  • 头歌MySQL——复杂查询
  • 接口自动化测试SOP标准流程
  • 如何在需求收集阶段避免遗漏关键用户?
  • 在Windows上部署RAGFlow
  • Python每日一练---第六天:罗马数字转整数
  • 东莞网站平台价格网站建设判断题
  • C/C++ char类型字符串直接赋值与分配内存赋值的区别
  • apache 建立网站优化网站搜索排名
  • 再论大模型不能通向AGI
  • 手机网站 动态 页面 好 静态页面好养猪网站建设规划书
  • 用 C 语言实现的回调函数案例,涵盖基础用法及不同消息机制(GUI 模拟、网络请求模拟、状态机、消息队列)
  • wordpress站群软件带网站的图片素材
  • 营销管理网站东莞市微客巴巴做网站
  • 龙华网站(建设信科网络)基层建设期刊在哪个网站上检索
  • PLCSIM影响我们的Ssh通信
  • 修文县生态文明建设局网站通号建设集团有限公司
  • 杭州开发区网站建设php网站作业模版
  • 网站菜单样式网站的例子
  • 嘉兴网站建议wordpress 编辑器 视频
  • 成品网页网站本地专业app开发公司在哪里
  • 清苑区建设局网站wordpress恢复主题初始值
  • 亿网行网站建设114企业网网站架构软件
  • 网站组织结构图深圳市建设交易网站
  • 做网站和seo流程南宁建设网站培训
  • 系列文章<八>(从LED显示屏的Gamma过曝问题问题到手机影像):从LED冬奥会、奥运会及春晚等大屏,到手机小屏,快来挖一挖里面都有什么
  • 【咨询】Android Studio 第三方手机模拟器对比【202511】
  • 服装类的网站建设营销型网站定做
  • a5建站长宁免费网站制作
  • 做企业网站找谁全自动行业管理系统
  • ubuntu下安装transition_amr_parser