[{"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}]
<>集成数组的初始化
int a[]={2,4,6,5,68,9,8,56,6};
* 直接用大括号给出数组中所有元素的初始值
* 不需要给出数组的大小,编译器来数
sizeof(a)/sizeof(a[0])
sizeof(a)得到数组整个的字节数的大小
sizeof(a[0])得到数组中单个元素所占的字节
* 集成初始化时的定位
int a[10]={[0]=2,[2]=3,6,}
//{2,0,3,6,0,0,0,0,0,0}
<>数组的赋值
* 数组本身不能被赋值,因此要将一个数组赋值给另一个数组必须采用遍历 for(i=0;i<length;i++) { b[i]=a[i]; }
<>数组运算
#include<stdio.h> int search(int key,int a[],int length) { int ret=1; int i;
for(i=0;i<length;i++){ if(a[i]==key){ ret=i; break; } } return ret; } int main(
void) { int a[]={2,4,6,7,1,3,5,9,11,13,23,14,32}; int x; int loc; printf(
"请输入一个数字:"); scanf("%d",&x); loc=search(x,a,sizeof(a)/sizeof(a[0])); if(loc!=-1)
{ printf("%d在%d个位置上",x,loc); }else{ printf("%d不存在",x); } return 0; }
数组作为函数的参数时:
* 不能在[]中给出数组的大小
* 不能再用sizeof来计算数组的元素个数
数组作为函数参数时,必须用另一个参数来传入数组的大小
<>数组构建素数表
//建立素数表 #define _CRT_SECURE_NO_WARNINGS 1 #include<stdio.h> int main() { const
int maxNumber = 100; int isPrime[100]; int i; int x; for (i = 0;i < maxNumber;i
++) { isPrime[i] = 1; } for (x = 2;x < maxNumber;x++) { if (isPrime[x]) { for (i
= 2;i * x < maxNumber;i++) { isPrime[i * x] = 0; } } } for (i = 2;i < maxNumber;
i++) { if (isPrime[i]) { printf("%d\t", i); } } printf("\n"); }