有1个数组:
int arr[] = {10,20,30,40,50,60,70,80,90,100};
请使用四种方式遍历方式将这个数组遍历出来
*/
#include <stdio.h>
int main(int argc, const char * argv[])
{
int arr[]={10,20,30,40,50,60,70,80,90,100};
int len=sizeof(arr)/sizeof(arr[0]);
int *p1=arr;
for (int i=0; i<len; i++)
{
printf("%d\n",*(p1+i));
}
printf("哈哈哈哈哈!\n");
for (int i=0; i<len; i++)
{
printf("%d\n",*(p1++));
}
printf("哈哈哈哈哈!\n");
for (int i=0; i<len; i++)
{
printf("%d\n",*(arr+i));
}
printf("哈哈哈哈哈!\n");
for (int i=0; i<len; i++)
{
printf("%d\n",arr[i]);
}
printf("哈哈哈哈哈!\n");
return 0;
}
|
|