Это массив, который я изучал на C++. Есть ли способ облегчить это дальше?Есть ли способ упростить этот массив целых цепей C++?
< < соиЬ "Массив целочисленных значений" < < End L,; cout < < "============= < < endl;
int value[5] = { 17, 34, 51, 68, 85 }; // Creates an integer array list that contain a series of 5 values
for (int loop = 0; loop < 5; loop++) {
cout << "Integer value " << loop << ": " << value[loop] << endl;
}
cout << endl << "Array of double values" << endl; // First endl creates a blank line
cout << "=======================" << endl;
double numbers[10] = { 12.1, 24.2, 36.3, 48.4, 60.5, 72.6, 84.7, 96.8, 212.9, 3.0 }; // Creates an double integer array list that contains a series of 10 values
for (int loop = 0; loop < 10; loop++) { // Loops array
// Adding example " numbers[loop] = 77; " would set every number to 77
cout << "Element at index " << loop << ": " << numbers[loop] << endl;
}
cout << endl << "Initializing with zero values" << endl; // First endl creates a blank line
cout << "=======================" << endl;
for (int loop = 0; loop < 1; loop++) { // Loops array
// Adding " numbers[loop] = 77; " would set every number to 77
cout << "Element at index " << loop << ": " << numbers[loop] << endl;
}
cout << endl << "Initializing with strings" << endl; // First endl creates a blank line
cout << "=======================" << endl;
// Array of strings
string text = ("Chair", "Table", "Plate") ;
; for (int loop = 0; loop < 3; loop++) { // Loops array
cout << "Element at index " << loop << ": " << text[loop] << endl;
return 0;
Не уверен, что вы хотите сделать – edtheprogrammerguy
, вы можете удалить 'int numberArray [8] = {};' он не имеет никакой цели. Никаких вычислений на самом деле не делается, так что вы подразумеваете под упрощением? – ryanpattison
Диапазон для цикла? – chris