"c language" algorithm "multiple ways to access an array

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.