⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 6xii.cpp

📁 《C/C++程序设计导论(第二版)》一书的程序源文件
💻 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 + -