zoukankan      html  css  js  c++  java
  • 输入和学生成绩的输出

    #include<stdio.h>
    
    /*
    	学生的结构的定义。
    	成员变量名称、卷号、受试者的结果。
    	两名学生从键盘读取信息。
    	最后,良好的背景输出谁在公告栏中承认比分淘汰。
    	假设同样的比分,在公告栏中一同显示出来。

    */ //定义一个结构体类型 struct Student { char name[20]; //名字 char idNum[20]; //学籍号 float score; }; void compare(struct Student stus[],int count); int main() { //定义结构体类型的结构体数组 struct Student stu[2]; for (int i = 0; i < 2; ++i) { printf("请输入第%d个学生的姓名: ",i+1); //输入学生的姓名 scanf("%s",stu[i].name); printf("请输入第%d个学生的学籍号: ",i+1); //输入学生的学籍号 scanf("%s",stu[i].idNum); printf("请输入第%d个学生的成绩: ",i+1); //输入学生的成绩 scanf("%f",&stu[i].score); } // //讲学生的打印信息 // for (int i = 0; i < 2; ++i) // { // struct Student *p = &stu[i]; // printf("姓名:%s 学籍号:%s 成绩:%.2f ",p->name,p->idNum,p->score); // } compare(stu,2); return 0; } void compare(struct Student stus[],int count) { float max = 0; struct Student *maxStu; for (int i = 0; i < count; ++i) { //取得学生的成绩 float score = stus[i].score; if (max < score) { max = score; maxStu = &stus[i]; } } if (stus[0].score == stus[1].score) { //讲学生的打印信息 for (int i = 0; i < 2; ++i) { struct Student *p = &stus[i]; printf("姓名:%s 学籍号:%s 成绩:%.2f ",p->name,p->idNum,p->score); } } else printf("学生信息的识别:名字:%s 卷号:%s 成就:%.2f ",maxStu->name,maxStu->idNum,maxStu->score); }


  • 相关阅读:
    eclipse的安装
    第一章:Javascript语言核心
    jQuery理解之(二)功能函数
    jQuery理解之(一)动画与特效
    jQuery实现单击和鼠标感应事件。
    jQuery使用之(五)处理页面的事件
    jQuery使用之(四)处理页面的表单元素
    jQuery使用之(三)处理页面的元素
    jQuery使用之(二)设置元素的样式
    jQuery使用之(一)标记元素属性
  • 原文地址:https://www.cnblogs.com/gcczhongduan/p/5040336.html
Copyright © 2011-2022 走看看