CODE[VS]1023 GPA计算
来源:互联网 发布:淘宝链接转淘客链接 编辑:程序博客网 时间:2024/05/22 17:30
题目:http://codevs.cn/problem/1023/
题解:
/* 1023 GPA计算 */#include <stdio.h>#define DEBUG/* 主函数入口 */ int main(int argc, char *argv[]) { int n; /* 课目数 */ float score, credit, gpa; /* 成绩,学分,gpa */ float sum_credit; /* 总学分 */ int i; /* 索引值 */ #ifdef DEBUG FILE *fp; if(NULL == (fp = fopen("data.txt", "r"))){ return 1; }#endif /* 获取课目数 */#ifdef DEBUG fscanf(fp, "%d", &n); #else scanf("%d", &n)#endif sum_credit = 0.0; gpa = 0.0; /* 获取课目成绩和学分 */ for(i = 1; i <= n; i++){#ifdef DEBUG fscanf(fp, "%f %f", &credit, &score);#else scanf("%f %f", &credit, &score);#endif sum_credit = sum_credit + credit; gpa = gpa + credit * score; } /* 计算GPA结果 */ gpa = gpa / sum_credit; /* 输出结果 */ printf("%0.2f", gpa); return 0;}
阅读全文
0 0
- CODE[VS]1023 GPA计算
- wikioi 1023 GPA计算
- 1023 GPA计算
- 【codevs 1023】GPA计算
- 【CodeVS】1023 GPA计算
- GPA计算
- 计算GPA
- GPA计算
- Code Vs 1137 计算系数
- 【基础练习】GPA计算
- GPA计算 UESTC
- code[vs] 1011 数的计算
- Code Vs-problem-1011 数的计算
- CODE[VS] 1011 数的计算
- 什么是GPA,应如何计算?
- 什么是GPA,应如何计算?
- 一个计算GPA的工具
- GPA
- Sublime Text 3143 注册码失效的问题
- 教你怎么把CAD图纸转为jpg高清图片
- redis源码阅读笔记-- 事件
- Java语法基础练习题1 2017/9/14
- java 反射 joor
- CODE[VS]1023 GPA计算
- Android中JSONObject与JsonObject的区别
- 搜索框提示相关内容
- Mybatis中#和$的区别
- android 浅尝JNI 打包so库
- Android中解决由单例引起的内存泄漏问题
- 遍历目录及子层目录下的所有文件
- 安卓5.1屏蔽recent_apps
- 应用程序无法正常启动(0xc000007b)。请单击确定关闭应用程序