当前位置: 首页 > news >正文

C++ primer plus(第六版)编程练习答案 第4章 复合类型

一、程序清单

arrayone.cpp 

// arrayone.cpp -- small arrays of integers
#include <iostream>
int main()
{using namespace std;int yams[3];    // creates array with three elementsyams[0] = 7;    // assign value to first elementyams[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"
http://www.lryc.cn/news/43083.html

相关文章:

  • Kafka源码分析之Producer(一)
  • springboot校友社交系统
  • python flask项目部署
  • 常见排序算法(C语言实现)
  • 基于jsp+ssm+springboot的小区物业管理系统【设计+论文+源码】
  • Elasticsearch 学习+SpringBoot实战教程(三)
  • try-with-resource
  • leetcode148_排序链表的3种解法
  • 使用stm32实现电机的PID控制
  • 数学原理—嵌入矩阵
  • English Learning - L2 语音作业打卡 辅音翘舌音 [ʃ] [ʒ] 空气摩擦音 [h] Day31 2023.3.23 周四
  • 记录springboot+vue+fastdfs实现简易的文件(上传、下载、删除、预览)操作
  • Java中循环使用Stream应用场景
  • 中国蚁剑AntSword实战
  • C++ 直接初始化和拷贝初始化
  • 数据迁移工具
  • 【C/C++】程序的内存开辟
  • 全网最完整,接口测试总结彻底打通接口自动化大门,看这篇就够了......
  • 28-flume和kafka为什么要结合使用
  • STM32外设-定时器详解
  • 史上最详细的改良顺序表讲解,看完不会你打我
  • 【Unity入门】资源包导入和导出
  • python条件语句与循环语句
  • 【leetcode】链表(2)
  • 使用Vue+vue-router+路由守卫实现路由鉴权功能实战
  • 多线程(三):Thread 类的基本属性
  • 蓝桥杯嵌入式第六课--串口收发
  • 蓝桥杯冲刺 - Lastweek - 你离省一仅剩一步之遥!!!(掌握【DP】冲刺国赛)
  • C++ map与set的学习
  • 【C语言初阶】函数