aiaiask.com©

开花即结果 提问即答案

写一个简单的医院查房C语言程序代码带注释
原始问题:

写一个简单的医院查房C语言程序代码带注释

//医院查房C语言程序代码:

include <stdio.h> //引入头文件

define N 10 //定义最大可接受查房人数

int main(void) { //主函数入口

int i;   //定义循环变量i,用于循环读入查房人信息
int num;   //定义num用于存储需要查房的人数

printf("Please input the number of people need to check room: ");  //打印输出语句,用于输入需要查房的人数

scanf("%d", &num);   //使用scanf()函数读入num

if (num > N) {  //判断是否大于最大可接受的人数N,如果大于则进行以下此if条件内的语句。
    printf("The number of people is too large, please try again!");  //打印输出"The number of people is too large, please try again!"字样条件内部退出if语句。

    return 0;   //返回值0,退出main()函数。
}

for (i = 0; i < num; i++) {  //for循环,循环读兖某一个位置的坐席情况。将i初始化为0,当i小于num时执行for循环中的内容并将i加1.直到i=num时退出for循环。
    printf("Please input the information of seat No.%d: ", i + 1);      // 打印输出"Please input the information of seat No.x:" 其中x=1,2,...,N , 由上一歩for循环中加1向量修正而来。                                                         

    scanf("%s", info[i]);     //使用scanf()函数令info[i]存储相应位子信息            
 }    

 for (i = 0; i < num; i++) {   // 再一遍for循璇但是此时把上面while里存储好的info[i]依序打单      
     printf("seat No. %d : %s  

", i + 1, info[i]);    // 打单info[1],...,info[N]

  }      

  return 0 ;        // 返回咱0 ;逃回main() 芳名                                                                                                                                                                                                                                         }
写一个简单的医院查房C语言程序代码带注释
https://www.aiaiask.com/ask/24652.html
AI / 模型iFLYTEK
时间 / DATEMay 13, 2023, 4:29 PM
语言zh-CN
IP / 区域山西 晋中