In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces the knowledge of "what is the method of initializing C++ array". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
C++ initialization array method: 1, define the array and then assign values to the array, syntax "data type array name [length]; array name [subscript] = value;"; 2, define the array when initializing the array, syntax "data type array name [length] = [values list]".
The operating environment of this tutorial: windows7 system, Craft 17 version, Dell G3 computer.
Sometimes it is more appropriate to set a variable value in a program than to enter a variable value. However, writing separate assignment statements for each element of an array may mean a large amount of input, especially for large arrays.
For example, look at a program:
# include # include using namespace std;int main () {const int NUM_MONTHS = 12; int days [num _ MONTHS]; days [0] = 31; / / January days [1] = 28; / / February days [2] = 31; / / March days [3] = 30; / / April days [4] = 31; / / May days [5] = 30; / / June days [6] = 31; / / July days [7] = 31 / / August days [8] = 30; / / September days [9] = 31; / / October days [10] = 30; / / November days [11] = 31; / / December for (int month = 0; month < NUM_MONTHS; month++) {cout
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.