#include < iostream >struct box{ char maker[40]; float height; float width; float length; float volume;};float find_volume(box *pst);void show_value(box b);int main(){ using namespace std; box b1 = {"box1", 10, 10, 10}; find_volume(&b1); show_value(b1); return 0;}float find_volume(box *pst){ using namespace std; pst->volume = pst->height * pst->length * pst->width; //cout << pst->volume; return pst->volume;}void show_value(box b){ using namespace std; cout << b.maker << "\n" << b.height << "\n" << b.width << "\n" << b.length << "\n" << b.volume << "\n";}
張貼留言
1 則留言:
#include < iostream >
struct box
{
char maker[40];
float height;
float width;
float length;
float volume;
};
float find_volume(box *pst);
void show_value(box b);
int main()
{
using namespace std;
box b1 = {"box1", 10, 10, 10};
find_volume(&b1);
show_value(b1);
return 0;
}
float find_volume(box *pst)
{
using namespace std;
pst->volume = pst->height * pst->length * pst->width;
//cout << pst->volume;
return pst->volume;
}
void show_value(box b)
{
using namespace std;
cout << b.maker << "\n"
<< b.height << "\n"
<< b.width << "\n"
<< b.length << "\n"
<< b.volume << "\n";
}
張貼留言