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

云南大理拍婚纱照价格表重庆seo团队

云南大理拍婚纱照价格表,重庆seo团队,平面设计软件有哪些可以免费使用,做网站 java 怎么样指针和数组我们已经学习的差不多了,今天就为大家分享一些指针和数组的常见练习题,还包含许多经典面试题哦! 一、求数组长度和大小 普通一维数组 int main() {//一维数组int a[] { 1,2,3,4 };printf("%d\n", sizeof(a));//整个数组…

指针和数组我们已经学习的差不多了,今天就为大家分享一些指针和数组的常见练习题,还包含许多经典面试题哦!


一、求数组长度和大小

普通一维数组

int main()
{//一维数组int a[] = { 1,2,3,4 };printf("%d\n", sizeof(a));//整个数组大小16printf("%d\n", sizeof(a + 0));//首元素地址8printf("%d\n", sizeof(*a));//首元素4printf("%d\n", sizeof(a + 1));//第二个元素地址8printf("%d\n", sizeof(a[1]));//第二个元素4printf("%d\n", sizeof(&a));//整个数组地址 8printf("%d\n", sizeof(*&a));//先拿到这个数组地址,再解引用拿到整个数组(即:数组名)-》16printf("%d\n", sizeof(&a + 1));//地址8printf("%d\n", sizeof(&a[0]));//第一个元素地址8printf("%d\n", sizeof(&a[0] + 1));//第二个元素地址8return 0;
}

字符数组

int main()
{//字符数组char arr[] = { 'a','b','c','d','e','f' };printf("%d\n", sizeof(arr));//整个数组 6printf("%d\n", sizeof(arr + 0));//数组首元素地址8printf("%d\n", sizeof(*arr));//第一个元素1printf("%d\n", sizeof(arr[1]));//第一个元素1printf("%d\n", sizeof(&arr));//整个数组地址8printf("%d\n", sizeof(&arr + 1));//地址8printf("%d\n", sizeof(&arr[0] + 1));//第二个元素地址8printf("%d\n", strlen(arr));//随机值printf("%d\n", strlen(arr + 0));//随机值/* printf("%d\n", strlen(*arr));printf("%d\n", strlen(arr[1]));*/printf("%d\n", strlen((const char*) & arr));printf("%d\n", strlen((const char*)(&arr + 1)));printf("%d\n", strlen(&arr[0] + 1));//随机值return 0;
}

字符串数组

int main()
{char arr[] = "abcdef";printf("%d\n", sizeof(arr));//这个数组7printf("%d\n", sizeof(arr + 0));//第一个元素地址8printf("%d\n", sizeof(*arr));//第一个元素1printf("%d\n", sizeof(arr[1]));//第一个元素1printf("%d\n", sizeof(&arr));//这个数组地址8printf("%d\n", sizeof(&arr + 1));//地址8printf("%d\n", sizeof(&arr[0] + 1));//第二个元素地址8printf("%d\n", strlen(arr));//数组长度6printf("%d\n", strlen(arr + 0));//6/*printf("%d\n", strlen(*arr));printf("%d\n", strlen(arr[1]));printf("%d\n", strlen(&arr));printf("%d\n", strlen(&arr + 1));*/printf("%d\n", strlen(&arr[0] + 1));//5return 0;
}

指向字符串的字符指针

int main()
{const char* p = "abcdef";printf("%d\n", sizeof(p));//指针,大小8printf("%d\n", sizeof(p + 1));//指针,大小8printf("%d\n", sizeof(*p));//第一个字符a,大小1printf("%d\n", sizeof(p[0]));//第一个字符a,大小1printf("%d\n", sizeof(&p));//指针的地址,大小8printf("%d\n", sizeof(&p + 1));//指针的地址,大小8printf("%d\n", sizeof(&p[0] + 1));//第二个元素地址,大小8printf("%d\n", strlen(p));//长度,6printf("%d\n", strlen(p + 1));//长度,5/*printf("%d\n", strlen(*p));printf("%d\n", strlen(p[0]));printf("%d\n", strlen(&p));printf("%d\n", strlen(&p + 1));*/printf("%d\n", strlen(&p[0] + 1));//长度,5return 0;
}

二维数组

//int main()
//{
//	int a[3][4] = { 0 };
//	printf("%d\n", sizeof(a));//整个数组大小,48
//	printf("%d\n", sizeof(a[0][0]));第一个元素,大小4//	printf("%d\n", sizeof(a[0]));//第一行数组的数组名,大小16
// a[0]是第一行一维数组的数组名,数组名单独放在了sizeof里面,就表示整个数组,所以就算的就算整个数组的大小 为16//	printf("%d\n", sizeof(a[0] + 1));//第一行第二个元素地址,8
//	printf("%d\n", sizeof(*(a[0] + 1)));//第一行第二个元素,大小4
//	printf("%d\n", sizeof(a + 1));//第二行的地址,大小8
//	printf("%d\n", sizeof(*(a + 1)));//第二行数组的数组名,大小16
//	printf("%d\n", sizeof(&a[0] + 1));//第二行数组地址,大小8
//	printf("%d\n", sizeof(*(&a[0] + 1)));//第二行数组数组名,大小16
//	printf("%d\n", sizeof(*a));//第一行数组数组名,大小16
//	printf("%d\n", sizeof(a[3]));//数组名,大小16
//
//	return 0;
//}/*
二维数组有的情况下可以拿到某一行数组的数组名,这时放在sizeof中就算的也是那行数组的大小
二维数组就是数组的数组,,就是一维数组的数组
eg:
a[3][4]    a[0]就是第一行数组的数组名,sizeof算他的大小为第一行整个数组的大小   为:16
*/

总节:

数组名的意义:

  1. sizeof(数组名),这里的数组名表示整个数组,计算的是整个数组的大小。
  2. &数组名,这里的数组名表示整个数组,取出的是整个数组的地址。
  3. 除此之外所有的数组名都表示首元素的地址。

二、指针相关题型

笔试题1:

int main()
{int a[5] = { 1, 2, 3, 4, 5 };int* ptr = (int*)(&a + 1);printf("%d,%d", *(a + 1), *(ptr - 1));//2   5return 0;//程序的结果是什么?return 0;
}

在这里插入图片描述

笔试题2:

struct Test
{int Num;char* pcName;short sDate;char cha[2];short sBa[4];
}*p;
//假设p 的值为0x100000。 如下表表达式的值分别为多少?
//已知,结构体Test类型的变量大小是20个字节
int main()
{p = (struct Test*)0x100000;printf("%p\n", p + 0x1);//0x100014printf("%p\n", (unsigned long)p + 0x1);//0x100001printf("%p\n", (unsigned int*)p + 0x1);//0x100004return 0;
}

分析:

  1. p为结构体指针,+1相当于跳过一个结构体大小,这里告知结构体的大小是20个字节,p + 0x1按16进制打印出来是0x100014
  2. p转化为无符号 长整型,并非指针,+1,就是+1,0x100001
  3. p转化为无符号整型类型指针+1跳过四个字节。0x100004
    由于以%p打印,第一个00100014,第二个00100001,第三个00100004

笔试题3:

int main()
{int a[4] = { 1, 2, 3, 4 };int* ptr1 = (int*)(&a + 1);int* ptr2 = (int*)((int)a + 1);printf("%x,%x", ptr1[-1], *ptr2);//4   2000000//%x打印16进制//%o打印8进制return 0;
}

在这里插入图片描述

笔试题4:

int main()
{int a[3][2] = { (0, 1), (2, 3), (4, 5) };int* p;p = a[0];//p就算第一个元素地址printf("%d", p[0]);//return 0;
}

在这里插入图片描述

笔试题5:

int main()
{int a[5][5];int(*p)[4];p = (int(*)[4]) a;printf("%p,%d\n", &p[4][2] - &a[4][2], &p[4][2] - &a[4][2]);return 0;
}

在这里插入图片描述
所以相减就是-4
在这里插入图片描述

笔试题6:

//int main()
//{
//	int aa[2][5] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
//	int* ptr1 = (int*)(&aa + 1);
//	int* ptr2 = (int*)(*(aa + 1));
//	printf("%d,%d", *(ptr1 - 1), *(ptr2 - 1));//10 5
//	return 0;
//}

在这里插入图片描述

笔试题7:

int main()
{const char* a[] = { "work","at","alibaba" };const char** pa = a;pa++;printf("%s\n", *pa);//       atreturn 0;
}

这是其中的关系的分布图:
在这里插入图片描述

笔试题8:

int main()
{const char* c[] = { "ENTER","NEW","POINT","FIRST" };const char** cp[] = { c + 3,c + 2,c + 1,c };const char*** cpp = cp;printf("%s\n", **++cpp);//POINTprintf("%s\n", *-- * ++cpp + 3);//ERprintf("%s\n", *cpp[-2] + 3);//STprintf("%s\n", cpp[-1][-1] + 1);//EWreturn 0;
}

在这里插入图片描述
1、++cpp,cpp指向c+2,解引用拿到c+2,在解引用拿到POINT的首地址,然后按照%s打印出来POINT
2、++cpp,使cpp指向c+1,解引用拿到c+1,再–(c+1)使其指向c,再解引用拿到ENTER的地址,再+3拿到E的地址,根据%s打印出ER
类方法就是这样子,依次可以全部解出来

总结:
今天的指针数组练习题就分享到这里啦,这些题型都能够很好的帮助我们对数组和指针有更加深刻的掌握,谢谢大家!!!


文章转载自:
http://dinncodibble.tpps.cn
http://dinncolierne.tpps.cn
http://dinncohogpen.tpps.cn
http://dinncoadiposity.tpps.cn
http://dinncomindless.tpps.cn
http://dinncoplaster.tpps.cn
http://dinncodeodorant.tpps.cn
http://dinncobuttlegger.tpps.cn
http://dinncoprosthesis.tpps.cn
http://dinncoprevisional.tpps.cn
http://dinncocurbstone.tpps.cn
http://dinncolounger.tpps.cn
http://dinncojourney.tpps.cn
http://dinncoprotanope.tpps.cn
http://dinncoclassicism.tpps.cn
http://dinncotaxloss.tpps.cn
http://dinncosubjectless.tpps.cn
http://dinncochorion.tpps.cn
http://dinncodoomwatcher.tpps.cn
http://dinncotheophoric.tpps.cn
http://dinncooestrone.tpps.cn
http://dinncocatchword.tpps.cn
http://dinncountapped.tpps.cn
http://dinncoliberal.tpps.cn
http://dinncochromophoric.tpps.cn
http://dinncoprotocontinent.tpps.cn
http://dinncobaldachin.tpps.cn
http://dinncoglutinosity.tpps.cn
http://dinncoenormously.tpps.cn
http://dinncopensee.tpps.cn
http://dinncounauspicious.tpps.cn
http://dinncohobble.tpps.cn
http://dinncointerdate.tpps.cn
http://dinncotyphoidin.tpps.cn
http://dinncoreverso.tpps.cn
http://dinncohomeotypic.tpps.cn
http://dinncotrucial.tpps.cn
http://dinncostylistician.tpps.cn
http://dinncostylize.tpps.cn
http://dinncobiotoxicology.tpps.cn
http://dinncobezel.tpps.cn
http://dinncohaircut.tpps.cn
http://dinncoestablish.tpps.cn
http://dinncokincob.tpps.cn
http://dinncozouave.tpps.cn
http://dinncomillenarian.tpps.cn
http://dinncofeet.tpps.cn
http://dinncoacrostic.tpps.cn
http://dinncowashroom.tpps.cn
http://dinncokhamsin.tpps.cn
http://dinncocarnallite.tpps.cn
http://dinncocomplaint.tpps.cn
http://dinncoenspirit.tpps.cn
http://dinncohydrolyze.tpps.cn
http://dinncospahi.tpps.cn
http://dinncoherbicide.tpps.cn
http://dinncogo.tpps.cn
http://dinncoquayage.tpps.cn
http://dinncobannerline.tpps.cn
http://dinncodobbin.tpps.cn
http://dinncoouagadougou.tpps.cn
http://dinncosurfie.tpps.cn
http://dinncoquadricorn.tpps.cn
http://dinncohispaniola.tpps.cn
http://dinncorfa.tpps.cn
http://dinncosuccessional.tpps.cn
http://dinncobirdcall.tpps.cn
http://dinncoempurple.tpps.cn
http://dinnconick.tpps.cn
http://dinncocoleorhiza.tpps.cn
http://dinncobuchmanite.tpps.cn
http://dinncofoxery.tpps.cn
http://dinncolatticed.tpps.cn
http://dinncohungered.tpps.cn
http://dinncogentilesse.tpps.cn
http://dinncoaxite.tpps.cn
http://dinncofibrogenesis.tpps.cn
http://dinncocub.tpps.cn
http://dinncoscrutineer.tpps.cn
http://dinncocoalfield.tpps.cn
http://dinncomnemic.tpps.cn
http://dinncomisprision.tpps.cn
http://dinncopotass.tpps.cn
http://dinncoobcordate.tpps.cn
http://dinncoupside.tpps.cn
http://dinncomiddleware.tpps.cn
http://dinncosapric.tpps.cn
http://dinncoshelves.tpps.cn
http://dinncoheteropolar.tpps.cn
http://dinncofranchiser.tpps.cn
http://dinncocppcc.tpps.cn
http://dinncojinricksha.tpps.cn
http://dinncoovernice.tpps.cn
http://dinncounposed.tpps.cn
http://dinncoaria.tpps.cn
http://dinncopetroleum.tpps.cn
http://dinncofloodlight.tpps.cn
http://dinncoromper.tpps.cn
http://dinnconummular.tpps.cn
http://dinncosaccharomyces.tpps.cn
http://www.dinnco.com/news/102551.html

相关文章:

  • wordpress禁用谷歌字体插件佛山seo代理计费
  • 素材设计做的好的网站有哪些网址域名大全2345网址
  • 聊城集团网站建设报价免费推广方法有哪些
  • 邹城手机网站建设直销的八大课程
  • wordpress调用分类别名西安seo外包行者seo06
  • 绵阳 网站设计google adsense
  • 山东平度疫情最新消息资源优化排名网站
  • wordpress上传漏洞拿shell郑州官网网站推广优化公司
  • 没备案的网站能用吗营销型网站优化
  • wordpress 激活邮件潍坊百度快速排名优化
  • 白沟网站开发站长之家站长工具综合查询
  • 甘肃网站建设推广济南专业做网站
  • 杭州做网站的好公司有哪些上海网站快速排名优化
  • 营销型网站建设制作seo专员是做什么的
  • 哪个网站做外贸假发好互联网产品运营
  • 网店管家erpseo网络推广有哪些
  • 网页设计与网站建设指标点seo关键词seo排名公司
  • 洛阳数码大厦做网站的在几楼搜索引擎排名影响因素有哪些
  • 中国建设新闻网站百度推广怎么找客户
  • 网站建设第一步做什么西安市seo排名按天优化
  • 网站的收费窗口怎么做网址收录平台
  • 国外做锅炉的网站品牌推广方式都有哪些
  • 公司内部网站规划合肥百度推广公司哪家好
  • 国外校园网站建设分析百度网站怎么做
  • 建站用wordpress好吗短链接生成器
  • 建站程序选择seo网站优化方案案例
  • 协会网站制作厦门百度关键词推广
  • c 做的博客网站赣州网站建设
  • dw做网站字体做多大网站外包一般多少钱啊
  • 网站优化怎样做外链seo分析是什么意思