[{"createTime":1735734952000,"id":1,"img":"hwy_ms_500_252.jpeg","link":"https://activity.huaweicloud.com/cps.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=V1g3MDY4NTY=&utm_medium=cps&utm_campaign=201905","name":"华为云秒杀","status":9,"txt":"华为云38元秒杀","type":1,"updateTime":1735747411000,"userId":3},{"createTime":1736173885000,"id":2,"img":"txy_480_300.png","link":"https://cloud.tencent.com/act/cps/redirect?redirect=1077&cps_key=edb15096bfff75effaaa8c8bb66138bd&from=console","name":"腾讯云秒杀","status":9,"txt":"腾讯云限量秒杀","type":1,"updateTime":1736173885000,"userId":3},{"createTime":1736177492000,"id":3,"img":"aly_251_140.png","link":"https://www.aliyun.com/minisite/goods?userCode=pwp8kmv3","memo":"","name":"阿里云","status":9,"txt":"阿里云2折起","type":1,"updateTime":1736177492000,"userId":3},{"createTime":1735660800000,"id":4,"img":"vultr_560_300.png","link":"https://www.vultr.com/?ref=9603742-8H","name":"Vultr","status":9,"txt":"Vultr送$100","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":5,"img":"jdy_663_320.jpg","link":"https://3.cn/2ay1-e5t","name":"京东云","status":9,"txt":"京东云特惠专区","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":6,"img":"new_ads.png","link":"https://www.iodraw.com/ads","name":"发布广告","status":9,"txt":"发布广告","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":7,"img":"yun_910_50.png","link":"https://activity.huaweicloud.com/discount_area_v5/index.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=aXhpYW95YW5nOA===&utm_medium=cps&utm_campaign=201905","name":"底部","status":9,"txt":"高性能云服务器2折起","type":2,"updateTime":1735660800000,"userId":3}]
15.数组遍历
#include <stdio.h> int main() { int arr[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
int i; for(i=0;i<10;i++) { printf("%d\n",arr[i]); } return 0; }
* 数组的冒泡排序
冒泡排序的思想:相邻元素两两比较,将较大的数字放在后面,直到将所有数字全部排序。
* 字符串与数组
在C语言中,是没有办法直接定义子字符串数据类型的,需使用数组来定义所要的字符串,形式如下:
* char 字符串名称[长度] = "字符串内容";
* char 字符串名称[长度] = {'字符串1','字符串2',....,'字符串n','\0'};
注:
* []中的长度可以省略不写;
* 采用第二种方式最后一个元素必须是'\0',表示结束;
* 第二种方式不能写中文!; 输出字符串时,要使用:printf("%s",字符数组名);或puts(字符数组名);
16.字符串函数
* strlen(s):获取字符串s的长度;
*
strcmp(s1,s2):比较字符串;比较的时候会把字符串转换成ASCII码再进行比较,返回结果为0表示s1和s2的ASCII码值相等,返回结果为1表示s1比s2的ASCII码大,返回结果为-1表示s1比s2的ACSII码小;
* strcpy(s1,s2):字符串拷贝;s2会取代s1中的内容;
* strcat(s1,s2)将s2拼接到s1后面;注意:s1的length要足够才可以!
* atoi(s1)将字符串转为整数!
17.多维数组
数据类型 数组名称[常量表达式1]...[常量表达式n];
多维数组的初始化与一维数组的初始化类似也是分两种:
* 数据类型 数组名称[常量表达式1][常量表达式2]...[常量表达式n] = {
{值1,..,值n},{值1,..,值n},...,{值1,..,值n}};
* 数据类型 数组名称[常量表达式1][常量表达式2]...[常量表达式n]; 数组名称[下标1][下标2]...[下标n] = 值;
多维数组初始化要注意以下事项:
* 采用第一种始化时数组声明必须指定列的维数。因为系统会根据数组中元素的总个数来分配空间,当知道元素总个数以及列的维数后,会直接计算出行的维数;
* 采用第二种初始化时数组声明必须同时指定行和列的维数。
18.多维度数组的遍历
使用嵌套循环
注意:多维数组的每一维下标均不能越界!