急!!!求大神!
某大學醫療資訊系統如下:
學號 姓名 性別 出生日期 身高 體重 過敏體質 高壓 低壓 BMI
201558501901 Hong Tao M 1997/01/02 1.80 70 Y 110 70 Medium
201558501902 Zhao Lan F 1998/10/08 1.60 75 Y 110 70 High
說明:
(1)學號由12位數字組成:其中1—4位:入學年份,5—9位:院系專業,10位:班級,11—12位:學生所在班級中的序號;
(2)身高單位為米、體重單位為公斤;
(3)BMI指數計算公式為:體重/身高的平方
(4)BMI指數正常范圍為:18.5—23.9;
請設計該醫療資訊系統:
(1)確定系統中各種資料的資料型別及小數保留位數;
(2)確定醫療資訊系統的輸入項;
(3)確定醫療資訊系統的計算項;
(4)確定醫療資訊系統的輸出項;
(5)輸出醫療系統中的全部學生資訊;
(6)輸出系統中BMI指數不正常的學生;
(7)輸出系統中BMI指數不正常的學生及學生所在的院系專業。
/
程式功能:根據提示輸出XX大學醫療資訊系統的學生資訊
輸入:學號 姓名 性別 出生日期 身高 體重 過敏體質 高壓 低壓
輸出:學號 姓名 性別 出生日期 身高 體重 過敏體質 高壓 低壓 BMI
(如果BMI不正常,則輸出學生名字和院系專業
#include<stdio.h>
int main()
{
/* 資料結構定義 */
long long number; /* 學號:201458503221 */
char name[20]; /* 姓名:HongTao */
char sex; /* 性別 */
char birthday[20]; /* 生日 */
double height; /* 身高 */
int weight; /* 體重 */
char Isallergy; /* 是否是過敏體質 */
int highblood; /* 高血壓 */
int lowblood ; /* 低血壓 */
double bmi; /* BMI的值 */
int major; /* 院系專業 */
/* 主控邏輯 */
printf("***********************XX大學的醫療資訊*****************************\n");
printf("***********************Enter example as follows:********************\n");
printf("學號 姓名 性別 出生日期 身高 體重 過敏體質 高壓 低壓\n");
printf("201558501901 HongTao M 1997/01/02 1.80 70 Y 110 70\n");
//輸入學號
printf("************************Output example as follows:*************************\n");
printf("學號 姓名 性別 出生日期 身高 體重 過敏體質 高壓 低壓 BMI\n");
printf("Enter :\n");
while(scanf("%I64d",&number)!=EOF)
{
/* 輸入該生的其他資訊 */
scanf("%s %c%s%lf%d %c%d%d",name,&sex,birthday,&height,&weight,&Isallergy,&highblood,&lowblood);
/* 按格式顯示該生資訊 */
printf("%I64d %s %c %s %.2lf %d %c %d %d ",number,name,sex,birthday,height,weight,Isallergy,highblood,lowblood);
/* 計算BMI */
bmi=weight/(height*height);
if(bmi<18.5)
printf("Low\n");
else if(bmi>23.9)
printf("High\n");
else
printf("Medium\n");
/*輸出系統中BMI指數不正常的學生及學生所在的院系專業*/
if(bmi<18.5||bmi>23.9)
{
printf("Exist student whose BMI is unnormal:\n");
/*輸出BMI不正常同學的姓名*/
printf("name:%s\n",name);
/*輸出BMI不正常同學的major*/
printf("please print his or her zhuanye:\n");
/*輸出該同學的專業*/
major=(number/10000)%10000;
printf("major in %d\n",major);
}
printf("***********************Enter example as follows:********************\n");
printf("學號 姓名 性別 出生日期 身高 體重 過敏體質 高壓 低壓\n");
printf("Enter :\n");
}
return 0;
}
這個程式中的
while(scanf("%I64d",&number)!=EOF)
{
/* 輸入該生的其他資訊 */
scanf("%s %c%s%lf%d %c%d%d",name,&sex,birthday,&height,&weight,&Isallergy,&highblood,&lowblood);
/* 按格式顯示該生資訊 */
printf("%I64d %s %c %s %.2lf %d %c %d %d ",number,name,sex,birthday,height,weight,Isallergy,highblood,lowblood);
可以換成別的嗎?
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/81369.html
標籤:疑難問題
