⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 arrayone.cpp

📁 一本很好的C++学习的丛书!初学者必看的
💻 CPP
字号:
// arrayone.cpp -- small arrays of integers#include <iostream>int main(){    using namespace std;    int yams[3];    // creates array with three elements    yams[0] = 7;    // assign value to first element    yams[1] = 8;    yams[2] = 6;    int yamcosts[3] = {20, 30, 5}; // create, initialize array// NOTE: If your C++ compiler or translator can't initialize// this array, use static int yamcosts[3] instead of// int yamcosts[3]    cout << "Total yams = ";    cout << yams[0] + yams[1] + yams[2] << endl;    cout << "The package with " << yams[1] << " yams costs ";    cout << yamcosts[1] << " cents per yam.\n";    int total = yams[0] * yamcosts[0] + yams[1] * yamcosts[1];    total = total + yams[2] * yamcosts[2];    cout << "The total yam expense is " << total << " cents.\n";    cout << "\nSize of yams array = " << sizeof yams;    cout << " bytes.\n";    cout << "Size of one element = " << sizeof yams[0];    cout << " bytes.\n";    return 0; }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -