📄 6xii.cpp
字号:
// ReadItem() Input a single data item from a patient log line
// ASSUMPTION: input lines conform to the documented format
// OUT: sex is returned as the letter `F' or `M' (if input)
// age is returned as an integer following the input `A' (if input)
// weight is returned as a float following the input `W' (if input)
#include <iostream.h>
const char WEIGHT = 'W';
const char AGE = 'A';
const char MALE = 'M';
const char FEMALE = 'F';
void ReadItem (char& sex, int& age, float& weight)
{ char prefix;
cin >> prefix; // first get the item prefix
if (prefix == WEIGHT)
cin >> weight;
else if (prefix == AGE)
cin >> age;
else if (prefix == MALE)
sex = prefix;
else if (prefix == FEMALE)
sex = prefix;
else cout << " ** illegal data item in patient input **" << endl;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -