Fundamentals of C + + programming 111-Arrays

Source: Internet
Author: User

1 //11-Array. cpp: The entry point that defines the console application. 2 //3 4#include"stdafx.h"5#include <iostream>6#include <climits>7 using namespacestd;8  //An array is a composite type that can store multiple data of the same type. 9 intMain ()Ten { One      A     Charcarray[Ten]; -     BOOLbarray[ -]; -     floatfarray[ the]; the     Doubledarray[ -]; -     intscorearray1[4] = { the, -,623, the};//the array is declared and initialized, and the array contains 20 data of type int.  -     intscorearray2[4] = { the, the};//the remaining unassigned values are assigned by default.  -     intScorearray3[] = { the, -,245,123, $,1, *,};//How many elements are added, and how long the array will be. +     //the Declaration and assignment of an array must be made in the same row, or an error will occur.  -     //an array of arrays cannot be assigned to each other.  +  A     //the newest way to initialize C + + at     intscorearray4[4]{ at, $, the,123,};//c++11 allows the "=" of the above three ways to be removed.  -  -     //find the corresponding data by index (subscript) of the array. The index starts at 0.  -cout << scorearray1[0] << Endl;//Do not access the non-existent index, access to the non-existent index program will not error, will provide an unknown data.  -cout << scorearray2[1] <<Endl; -cout << scorearray3[3] <<Endl; incout << scorearray4[2] <<Endl; -      toscorearray1[1] = -;//replaces the value corresponding to the specified index in the array.  +  -     intT; theCin>>T; *     return 0; $}

Fundamentals of C + + programming 111-Arrays

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.