SZU:G32 Mass fraction
Judge Info
- Memory Limit: 32768KB
- Case Time Limit: 5000MS
- Time Limit: 5000MS
- Judger: Float Numbers (1e-4) Judger
Description
The chemists are well known because of their weird. Especially when they add water or salt in the same beaker over and over again. Moreover, the still hope you can tell him the mass fraction of the liquor after many operations. In case of your forgetting your junior school chemistry class, now we particularly give you the formula of the mass fraction.
w=a/(a+b)×100% here w means the mass fraction, a means the mass of the salt, and b means the mass of water.
Input
The first line contains two integers, representing the mass of water and salt initially. Than each line will represent a operation. The operation contains:
- 1. To add some salt into the beaker, the code is "salt x". x is a float number meaning the measure of salt The chemists add
- 2. To add some water into the beaker, the code is "water x". x is a float number meaning the measure of water The chemists add
- 3. Showing the mass fraction currently and the code is "show".
- 4. Exit the test. The code is "exit".
The number will not be larger than 1e9.
Output
Output should be according to the operation. Print the mass fraction of the liquor. All the answer has an absolute error within 1e-4, will be consider as correct answer.
Sample Input
1.5 0.5
salt 0.5
water 1.5
show
exit
Sample Output
0.25
解题思路:printf("%g\n", a/sum); %g 指省略后面所有无效的0。 虽然这题很简单,但是每一道水题都要认真对待并且总结。
#include <stdio.h>
#include <string.h> char A[]; int main()
{
float a,b,sum,c,d;
scanf("%f%f",&b,&a);
while(){
memset(A,'\0',sizeof(A));
scanf("%s", A);
if(strcmp(A,"salt")==){
scanf("%f",&c);
a+=c;
continue;
}
if(strcmp(A,"water")==){
scanf("%f",&d);
b+=d;
continue;
}
if(strcmp(A,"show")==){
sum=a+b;
printf("%g\n", a/sum);
continue;
}
if(strcmp(A,"exit")==){
break;
} }
return ;
}
SZU:G32 Mass fraction的更多相关文章
- R语言学习
1.清屏 Ctrl + L 2.退出 q() 3.设置工作空间 getwd() setwd('D:\\Program Files\\RStudio\\workspace') 4.显档当前工作目录下的文 ...
- jet flow in a combustion chamber
Table of Contents 1. contacts 2. Paper digest 2.1. LES vs. RANS 2.2. Dynamics of Transient Fuel Inje ...
- FLUENT质量加权平均和面积加权平均的区别【转载】
转载自:http://blog.sina.com.cn/s/blog_7ef78d170101bhfn.html 网上关于fluent中质量加强平均(Mass-Weighted Average)和面积 ...
- Usage of hdf2v3 and hdf2file
备注 修改Filetype,再执行hdf2file或hdf2tab,可以输出不同类型的数据.把Filetype设置成8,就是 Tecplot 格式的数据. <!DOCTYPE html PUBL ...
- Journal of Proteome Research | Prediction of an Upper Limit for the Fraction of Interprotein Cross-Links in Large-Scale In Vivo Cross-Linking Studies (分享人:张宇星)
题目:Prediction of an Upper Limit for the Fraction of Interprotein Cross-Links in Large-Scale In Vivo ...
- 新手!mass 设置问题
mass就是你那个物体的质量啊质量越大,惯性也越大重力也越大.假如你的刚体的mass为1,那么你只要给这个物体9.81N向上的力,你就可以抵消重力,让这个物体悬浮着:但假如这个物体的mass为10,你 ...
- [LeetCode] Fraction to Recurring Decimal 分数转循环小数
Given two integers representing the numerator and denominator of a fraction, return the fraction in ...
- How to: Change Sales Rep/Team via Mass Update
/* from: https://netsuite.custhelp.com/app/answers/detail/a_id/30057/kw/reassign%20sales */ How to c ...
- Fraction to Recurring Decimal
Given two integers representing the numerator and denominator of a fraction, return the fraction in ...
随机推荐
- [TroubleShooting] The remote copy of database xx has not been rolled forward to a point in time
Steps: 1. backup database TestMirror on Pricipal server 2. backup database log of TestMirror on Pric ...
- SpringMVC + Spring 3.2.14 + Hibernate 3.6.10
SpringMVC + Spring 3.2.14 + Hibernate 3.6.10 集成详解 注:此文档只说明简单的框架集成,各个框架的高级特性未涉及,刚刚接触框架的新人可能需要参考其他资料. ...
- 解决 configure.ac:17: error: possibly undefined macro: AC_PROG_LIBTOOL
当安装configure.ac:17: error: possibly undefined macro: AC_PROG_LIBTOOL If this token and others are le ...
- 沃森Mysql数据库修复工具
华信Mysql数据库修复程序是由北京华信数据恢复中心独立研发.主要针对Mysql数据库损坏的恢复. 本程序可用于因为各种误操作而导致数据丢失的恢复,以及因为断电.陈列损坏.硬盘坏道等各种原因导致数据库 ...
- c#有关udp可靠传输(包传输数据包) 升级
在c#有关udp可靠传输(包传输数据包)我们讨论,UDP包的发送,可是上一个程序有一个问题.就是数据比較大.一个Message类序列化后都有2048B,而实际的数据量也就只是 50B罢了,这就说明当中 ...
- 一些有用的javascript实例分析(一)
原文:一些有用的javascript实例分析(一) 本文以http://fgm.cc/learn/链接的实例索引为基础,可参见其实际效果.分析和整理了一些有用的javascript实例,相信对一些初学 ...
- 《STL源代码分析》---stl_list.h读书笔记
STL在列表list它是一种经常使用的容器.list不连续双向链表在内存,而且是环形. 理解列表如何操作的详细信息,然后.阅读STL名单上的代码是最好的方法. G++ 2.91.57.cygnus\c ...
- hdu 2066 一个人的旅行 最短路径
一个人的旅行 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Sub ...
- java 中关于json的使用方法
json在数据传输起了很大的作用,下面说说java中json的使用方法. 文章参考:http://www.codes51.com/article/detail_99574.html json串示例 [ ...
- webkit的几个属性
-webkit-text-size-adjust 1.当样式表里font-size<12px时,中文版chrome浏览器里字体显示仍为12px,这时可以用 html{-webkit-text-s ...