c++ 结构体,设置物品体积并输出物品属性
2024-09-20 11:30:17
#include <iostream>
using namespace std; struct box {
char maker[40];
float height;
float width;
float length;
float volume;
}; void displayBox(const box b);
void setVolume(box * b); int main() {
box b = {"abc", 3, 4, 5, 0};
setVolume(&b);
displayBox(b);
return 0;
} void displayBox(const box b) {
cout << "maker: " << b.maker << endl;
cout << "height: " << b.height << endl;
cout << "width: " << b.width << endl;
cout << "length: " << b.length << endl;
cout << "volume: " << b.volume << endl;
} void setVolume(box * b) {
b->volume = b->length*b->width*b->height;
}
最新文章
- 使用UIKit制作卡牌游戏(一)ios游戏篇
- WWDC2014总结---For产品经理们
- springmvc下上传文件
- ios多语言设置,操作
- 【原】linux系统运维工具必备
- typedef和自定义结构体类型
- WCF开发时如何选择正确的实例模式(InstanceMode)?
- hdu 1063 Exponentiation (高精度小数乘法)
- NOI十连测 第六测 T3
- php数组操作小结
- bootstrap之DumpWindowHierarchy
- Ubuntu下OpenCV不能被某个python版本识别
- Scrapy框架-Spider
- Oracle中的substr()函数 详解及应用
- monit检测语法
- python练习题-day8
- Java MongoDB
- 简易扩展Visual Studio UnitTesting支持TestMethodCase
- 超炫jQuery测试答题功能
- Apache2.4配置(全)