C语言数组a[i]==i[a]
来源:互联网 发布:java定义日期变量 编辑:程序博客网 时间:2024/06/05 07:53
The C standard defines the [] operator as follows:
a[b] == *(a + b)
Therefore a[5] will evaluate to:
*(a + 5)
and 5[a] will evaluate to:
*(5 + a)
and from elementary school math we know those are equal.
This is the direct artifact of arrays behaving as pointers, “a” is a memory address. “a[5]” is the value that’s 5 elements further from “a”. The address of this element is “a + 5″. This is equal to offset “a” from “5” elements at the beginning of the address space (5 + a).
#include <stdio.h>int main(){int a[10]={9,2,3,4,7,6,5,8,1,10};//a[b]=*(a+b)printf("%d\n",a[5]);printf("%d\n",*(a+5));printf("%d\n",*(5+a));printf("%d\n",5[a]);return 0;}
0 0
- C语言数组a[i]==i[a]
- C语言数组特性-取下标运算中的交换律----i[a] == a[i]
- C语言中a[++i],a[i++]
- a[i] = i++;
- 数组a[i++]=j 与 a[i]++ 的区别
- C,数组指针,*(a+i)与*a+i;
- C语言:scanf("%s",a)和gets(a)的区别(a[i]是字符串数组)
- 剑指Offer——构建数组B[i]=A[0]*A[1]*....A[i-1]*A[i+1]*A[i+2]*...A[n-1],不能使用除法
- for( i=0; i<5; a[i] = i++);
- i++/++i/a=a+b/a+=b
- 确定升序数组中使得A[i] = i 的整数i值
- A C I D
- N个元素的有序数组A,判断是否有 A[i]=i 存在
- 数组逆序关键是 b[i]=a[a.length-1-i]
- cuda计算C[i][j]=A[i][j]+B[i][j]
- 逆向输出一个数组(头尾交换,a[i]与a[n-i-1]交换,i<=(n-1)/2)
- 【谷歌面试题】给出一个数组A,找出一对 (i, j)使得A[i] <= A[j] (i < j)并且j-i最大
- 三个已排序的数组a,b,c,求i,j,k使a[i]=b[j]=c[k]
- PureMVC(AS3)剖析:实例
- poj 3280 区间dp
- 使用 Spring Boot 快速构建 Spring 框架应用
- 利用windows定时任务备份项目
- 对于Linux内核tty设备的一点理解
- C语言数组a[i]==i[a]
- 在eclipse中关联Hadoop源代码
- Web前端问题总结A
- 视频通话问题总结
- 编写自己的JDBC框架(九)
- js计算日期之间天数
- Java基础02——String
- Java基础05——多线程<三>
- 初步使用HTMLParser工具包【部分代码来自网络】