鱼C论坛

 找回密码
 立即注册

C++Primer Plus第6版编程练习7.13-3

已有 104 次阅读2015-7-3 21:18 |个人分类:c++Primer Plus 第6版编程练习笔记

#include <iostream>

using namespace std ;

struct box
{
    char maker[40] ;
    float height ;
    float width ;
    float length ;
    float volume ;
};

void show_box(box pa) ;
void set_volume(box *pb) ;
int main()
{
    struct box b1 ={"Tony",1.5,2.5,3,0} ;
    set_volume(&b1) ;
    show_box(b1) ;
    return 0;
}

void show_box( box pa)
{
    cout<<pa.maker<<endl ;
    cout<<pa.height<<endl ;
    cout<<pa.width<<endl ;
    cout<<pa.length<<endl ;
    cout<<pa.volume<<endl ;
}

void set_volume(box *pb)
{
    pb->volume=pb->height*pb->length*pb->width ;
}

路过

鸡蛋

鲜花

握手

雷人

评论 (0 个评论)

facelist

您需要登录后才可以评论 登录 | 立即注册

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-6-2 03:07

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

返回顶部