- //
- // main.c
- // HomeWork_05
- //
- // Created by 蒋伟 on 16/5/14.
- // Copyright (c) 2016年 蒋伟. All rights reserved.
- //
- #include <stdio.h>
- int main(int argc, const char * argv[]) {
- int arr[] = {34,234,32,534,6,257,356,8,35,24,5};
- int length = sizeof(arr) / sizeof(int);
- int *p1 = arr;
- printf("第一种遍历方式:\n");
- for(int i = 0; i < length; i++){
- printf("%d ",arr[i]);
- }
- printf("\n第二种遍历方式:\n");
- for(int i = 0; i < length; i++){
- printf("%d ",*(p1 + i));
- }
- printf("\n第三种遍历方式:\n");
- for(int i = 0; i < length; i++){
- printf("%d ",*(arr + i));
- }
- printf("\n第四种遍历方式:\n");
- for(int i = 0; i < length; i++){
- printf("%d ",*(p1++));
- }
- p1 = arr;
- return 0;
- }
复制代码
|
|