struct_ret.cpp
来自「数据结构常用算法合集」· C++ 代码 · 共 26 行
CPP
26 行
//struct_ret.cpp
#include <iostream.h>
#include <conio.h>
struct rec
{ float price;
int quantity;
float total;
};
rec get_struct();
void main()
{ rec items;
items=get_struct();
cout << "price=" << items.price << endl;
cout << "quantity=" <<items.quantity << endl;
cout << "Total=" << items.total << endl;
getch();
}
//get_struct()
rec get_struct()
{ rec r;
cout << "输入单价与数量:";
cin>>r.price>>r.quantity;
r.total=r.price*r.quantity;
return r;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?