UVA - 12412 A Typical Homework (a.k.a Shi Xiong Bang Bang Mang)

本文介绍了一个学生学业管理系统的实现,包括添加、删除、查询、展示排名和统计数据等功能。通过处理EPS问题,系统确保了数据的准确性。详细阐述了如何使用C语言进行系统开发,以及在实现过程中遇到的挑战和解决方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

//

看了书又看了网上的代码敲出来的, 汗, 自己敲是很难做出来的

//

进步之处, 处理EPS 问题, 代码在后面

//

#include<stdio.h>
#include<string.h>
#define EPS 1e-5
const int maxn = 1000;
const int maxl = 10 + 5;
int n;
int removed[maxn];
char sid[maxn][maxl];
int cid[maxn];
char name[maxn][maxl];
int score[maxn][5];
const char *course_name[]={"Chinese","Mathematics","English","Programming"};
void print_menu()
{
    printf("Welcome to Student Performance Management System (SPMS).\n");
    printf("\n");
    printf("1 - Add\n");
    printf("2 - Remove\n");
    printf("3 - Query\n");
    printf("4 - Show ranking\n");
    printf("5 - Show Statistics\n");
    printf("0 - Exit\n");
    printf("\n");
}

int valid(int k)
{
    for (int i=0;i<k;i++)
    {
        if(!removed[i])
        {
            if(!strcmp(sid[i],sid[k])) return 0;
        }
    }
    return 1;
}

void add()
{
    for(;;)
    {
        printf("Please enter the SID, CID, name and four scores. Enter 0 to finish.\n");
        scanf("%s",sid[n]);
        if(!strcmp(sid[n],"0")) break;
        scanf("%d%s%d%d%d%d",&cid[n],name[n],&score[n][0],&score[n][1],&score[n][2],&score[n][3]);
        if(valid(n))
        {
            score[n][4]=score[n][0]+score[n][1]+score[n][2]+score[n][3];
            n++;
        }
        else
            printf("Duplicated SID.\n");
    }
}
int rank(int k)
{
    int r=0;
    for(int i=0;i<n;i++)
    {
         if(!removed[i]&&score[i][4]>score[k][4]) r++;
    }
    return r+1;
}
void DQ (int isq)
{
    char s[maxl];
    for(;;)
    {
        printf("Please enter SID or name. Enter 0 to finish.\n");
        scanf("%s",s);
        if(!strcmp (s, "0"))
            break;
        int r=0;
        for(int i=0;i<n;i++)
            if(!removed[i])
            {
                if(!strcmp(sid[i],s)||!strcmp(name[i],s))
                {
                    if(isq)
                        printf("%d %s %d %s %d %d %d %d %d %.2f\n",rank(i),sid[i],cid[i],name[i],score[i][0],score[i][1],score[i][2],score[i][3],score[i][4],score[i][4]/4.0+EPS);
                    else
                    {
                        removed[i]=1;
                        r++;
                    }
                }
            }
        if(!isq)
            printf("%d student(s) removed.\n",r);
    }
}
double get_course_stat(int c,int s,int* passed,int* failed)
{
    int tot=0;
    *passed=*failed=0;
    for(int i=0;i<n;i++)
    {
        if(!removed[i]&&(!c||cid[i]==c))
        {
            tot+=score[i][s];
            if(score[i][s]>=60)
                (*passed)++;
            else
                (*failed)++;
        }
    }
    return (double)tot/(double)(*passed+*failed);
}
void get_overall_stat(int c,int* cnt)
{
    memset(cnt, 0, sizeof(cnt));
    for(int i=0;i<n;i++)
    {
        if(!removed[i]&&(!c||cid[i]==c))
        {
            int k=0;
            for(int j=0;j<4;j++)
            {
                if(score[i][j]>=60) k++;
            }
            cnt[k]++;
        }
    }
}
void stat()
{
    int c;
    printf("Please enter class ID, 0 for the whole statistics.\n");
    scanf("%d", &c);
    for(int i=0;i<4;i++)
    {
        int passed,failed;
        double avg=get_course_stat(c,i,&passed,&failed);
        printf("%s\n",course_name[i]);
        printf("Average Score: %.2f\n",avg+EPS);
        printf("Number of passed students: %d\n",passed);
        printf("Number of failed students: %d\n",failed);
        printf("\n");
    }
    int cnt[5];
    get_overall_stat(c,cnt);
    printf("Overall:\n");
    printf("Number of students who passed all subjects: %d\n",cnt[4]);
    printf("Number of students who passed 3 or more subjects: %d\n",cnt[4]+cnt[3]);
    printf("Number of students who passed 2 or more subjects: %d\n",cnt[4]+cnt[3]+cnt[2]);
    printf("Number of students who passed 1 or more subjects: %d\n",cnt[4]+cnt[3]+cnt[2]+cnt[1]);
    printf("Number of students who failed all subjects: %d\n",cnt[0]);
    printf("\n");
}
int main()
{
    for(;;)
    {
        int choice;
        print_menu();
        scanf("%d",&choice);
        if(choice==0) break;
        if(choice==1) add();
        if(choice==2) DQ(0);
        if(choice==3) DQ(1);
        if(choice==4) printf("Showing the ranklist hurts students' self-esteem. Don't do that.\n");
        if(choice==5) stat();
    }
    return 0;
}

EPS问题:
#include<stdio.h>
int main()
{
    double f;
    for(f = 2;  f > 1; f-= 1e-6);
    printf("%.7f\n", f);
    printf("%.7f\n", f/4);
    printf("%.1f\n", f/4);
    return 0;
}

输出:
0.9999990

0.2499998

0.2

在减1e-6的过程中有误差, 所以一遍采取加上一个EPS输出, EPS通常比最低精度还要小几个数量级的小实数

【基于QT的调色板】是一个使用Qt框架开发的色彩选择工具,类似于Windows操作系统中常见的颜色选取器。Qt是一个跨平台的应用程序开发框架,广泛应用于桌面、移动和嵌入式设备,支持C++和QML语言。这个调色板功能提供了横竖两种渐变模式,用户可以方便地选取所需的颜色值。 在Qt中,调色板(QPalette)是一个关键的类,用于管理应用程序的视觉样式。QPalette包含了一系列的颜色角色,如背景色、前景色、文本色、高亮色等,这些颜色可以根据用户的系统设置或应用程序的需求进行定制。通过自定义QPalette,开发者可以创建具有独特视觉风格的应用程序。 该调色板功能可能使用了QColorDialog,这是一个标准的Qt对话框,允许用户选择颜色。QColorDialog提供了一种简单的方式来获取用户的颜色选择,通常包括一个调色板界面,用户可以通过滑动或点击来选择RGB、HSV或其他色彩模型中的颜色。 横渐变取色可能通过QGradient实现,QGradient允许开发者创建线性或径向的色彩渐变。线性渐变(QLinearGradient)沿直线从一个点到另一个点过渡颜色,而径向渐变(QRadialGradient)则以圆心为中心向外扩散颜色。在调色板中,用户可能可以通过滑动条或鼠标拖动来改变渐变的位置,从而选取不同位置的颜色。 竖渐变取色则可能是通过调整QGradient的方向来实现的,将原本水平的渐变方向改为垂直。这种设计可以提供另一种方式来探索颜色空间,使得选取颜色更为直观和便捷。 在【colorpanelhsb】这个文件名中,我们可以推测这是与HSB(色相、饱和度、亮度)色彩模型相关的代码或资源。HSB模型是另一种常见且直观的颜色表示方式,与RGB或CMYK模型不同,它以人的感知为基础,更容易理解。在这个调色板中,用户可能可以通过调整H、S、B三个参数来选取所需的颜色。 基于QT的调色板是一个利用Qt框架和其提供的色彩管理工具,如QPalette、QColorDialog、QGradient等,构建的交互式颜色选择组件。它不仅提供了横竖渐变的色彩选取方式,还可能支持HSB色彩模型,使得用户在开发图形用户界面时能更加灵活和精准地控制色彩。
标题基于Spring Boot的二手物品交易网站系统研究AI更换标题第1章引言阐述基于Spring Boot开发二手物品交易网站的研究背景、意义、现状及本文方法与创新点。1.1研究背景与意义介绍二手物品交易的市场需求和Spring Boot技术的适用性。1.2国内外研究现状概述当前二手物品交易网站的发展现状和趋势。1.3论文方法与创新点说明本文采用的研究方法和在系统设计中的创新之处。第2章相关理论与技术介绍开发二手物品交易网站所涉及的相关理论和关键技术。2.1Spring Boot框架解释Spring Boot的核心概念和主要特性。2.2数据库技术讨论适用的数据库技术及其在系统中的角色。2.3前端技术阐述与后端配合的前端技术及其在系统中的应用。第3章系统需求分析详细分析二手物品交易网站系统的功能需求和性能需求。3.1功能需求列举系统应实现的主要功能模块。3.2性能需求明确系统应满足的性能指标和安全性要求。第4章系统设计与实现具体描述基于Spring Boot的二手物品交易网站系统的设计和实现过程。4.1系统架构设计给出系统的整体架构设计和各模块间的交互方式。4.2数据库设计详细阐述数据库的结构设计和数据操作流程。4.3界面设计与实现介绍系统的界面设计和用户交互的实现细节。第5章系统测试与优化说明对系统进行测试的方法和性能优化的措施。5.1测试方法与步骤测试环境的搭建、测试数据的准备及测试流程。5.2测试结果分析对测试结果进行详细分析,验证系统是否满足需求。5.3性能优化措施提出针对系统性能瓶颈的优化建议和实施方案。第6章结论与展望总结研究成果,并展望未来可能的研究方向和改进空间。6.1研究结论概括本文基于Spring Boot开发二手物品交易网站的主要发现和成果。6.2展望与改进讨论未来可能的系统改进方向和新的功能拓展。
1. 用户与权限管理模块 角色管理: 学生:查看个人住宿信息、提交报修申请、查看卫生检查结果、请假外出登记 宿管人员:分配宿舍床位、处理报修申请、记录卫生检查结果、登记晚归情况 管理员:维护楼栋与房间信息、管理用户账号、统计住宿数据、发布宿舍通知 用户操作: 登录认证:对接学校统一身份认证(模拟实现,用学号 / 工号作为账号),支持密码重置 信息管理:学生完善个人信息(院系、专业、联系电话),管理员维护所有用户信息 权限控制:不同角色仅可见对应功能(如学生无法修改床位分配信息) 2. 宿舍信息管理模块 楼栋与房间管理: 楼栋信息:名称(如 "1 号宿舍楼")、层数、性别限制(男 / 女 / 混合)、管理员(宿管) 房间信息:房间号(如 "101")、户型(4 人间 / 6 人间)、床位数量、已住人数、可用状态 设施信息:记录房间内设施(如空调、热水器、桌椅)的配置与完好状态 床位管理: 床位编号:为每个床位设置唯一编号(如 "101-1" 表示 101 房间 1 号床) 状态标记:标记床位为 "空闲 / 已分配 / 维修中",支持批量查询空闲床位 历史记录:保存床位的分配变更记录(如从学生 A 调换到学生 B 的时间与原因) 3. 住宿分配与调整模块 住宿分配: 新生分配:管理员导入新生名单后,宿管可按专业集中、性别匹配等规则批量分配床位 手动分配:针对转专业、复学学生,宿管手动指定空闲床位并记录分配时间 分配结果公示:学生登录后可查看自己的宿舍信息(楼栋、房间号、床位号、室友列表) 调整管理: 调宿申请:学生提交调宿原因(如室友矛盾、身体原因),选择意向宿舍(需有空位) 审批流程:宿管审核申请,通过后执行床位调换,更新双方住宿信息 换宿记录:保存调宿历史(申请人、原床位、新床位、审批人、时间) 4. 报修与安全管理模块 报修管理: 报修提交:学生选择宿舍、设施类型(如 "
### Core-Services Version 1.0.63 NPM Package Details The `core-services` package with version `^1.0.63` is not explicitly detailed in the provided references, but based on standard npm practices and conventions, the following information can be inferred about its details and dependencies: #### Package Description The `core-services` package typically serves as a foundational library for applications requiring common utilities or services. It may include modules for authentication, logging, caching, database connections, or other reusable components. While specific details of version `^1.0.63` are unavailable, such packages generally follow semantic versioning rules[^4]. #### Installation To install the `core-services` package with version `^1.0.63`, use the following command: ```bash npm install core-services@^1.0.63 ``` This ensures that the installed version satisfies the range specified by `^1.0.63`. #### Dependencies While the exact dependency tree for `core-services@^1.0.63` is unknown without direct access to its `package.json`, typical dependencies for similar packages might include: - **Utility Libraries**: Such as `lodash` or `underscore`. - **Logging Frameworks**: For example, `winston` or `pino`. - **Authentication Services**: Like `passport` or `jsonwebtoken`. - **Database Clients**: If applicable, libraries such as `mongoose` or `sequelize`. An example dependency structure could look like this: ```json { "dependencies": { "lodash": "^4.17.21", "winston": "^3.8.2", "jsonwebtoken": "^8.5.1", "axios": "^0.27.2" } } ``` This hypothetical structure aligns with common patterns observed in service-oriented packages[^5]. #### Common Issues If encountering issues during installation, consider the following troubleshooting steps: - Ensure compatibility between `core-services` and other project dependencies. - Verify that all required native modules are properly installed and configured (e.g., GTK-related DLLs mentioned in the context[^1]). - Set environment variables appropriately if SSL/TLS configurations are involved[^2]. #### Semantic Versioning The caret (`^`) prefix indicates that any patch-level updates (e.g., from `1.0.63` to `1.0.64`) will be automatically resolved by npm. However, major or minor version changes require explicit approval due to potential breaking changes[^4]. --- ###
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值