1#include <stdio.h>2 3 //Enter and output all elements of an array using the array name and pointer variables, and the following standard and pointer methods4 5 intMain () {6 intI=0;7 intarray[6];8 int*p=Array;9printf"\ nyou input array[6]: \ n");Ten while(p< (array+6)) Onescanf"%d", p++); Aprintf"\ n Output array[i]: \ n"); - for(i=0;i<6; i++)/*(1) array name, subscript method*/ -printf"%d,", Array[i]); theprintf"\ n Output * (array+i): \ n"); - for(i=0;i<6; i++)/*(2) array name, pointer method*/ -printf"%d,", * (array+i)); -printf"\ n Output p[i]: \ n"); +p=Array; - for(i=0;i<6; i++)/*(3) pointer variable, subscript method*/ +printf"%d,", P[i]); Aprintf"\ n Output * (p+i): \ n"); at for(i=0;i<6; i++)/*(4) Pointer variable, pointer method*/ -printf"%d,", * (p+i)); -printf"\ n Output *p++: \ n"); - while(p< (array+6))/*(5) Pointer variable, pointer method, the most efficient*/ -printf"%d,", *p++); -printf"\ n"); in return 0; -}
"c language" algorithm "multiple ways to access an array