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 ...
随机推荐
- SSH没有password安全日志
client: ssh-keygen -t rsa server结束 mkdir .ssh chmod 755 .ssh 从公开密钥client上传server scp .ssh/id_rsa.phb ...
- Hybrid----U采用IWebView演出PDF和其他文件
App如果你需要显示pdf.word档,在这个时候有没有其他控制,比UIWebView更适合,这是高度抽象的技术细节,可以非常easy采用 UIWebView打开文件类型列表 watermark/2/ ...
- who is the best?
Description There are N people want to choose the best person. Each person select the best person $a ...
- 自定义View视图
自定义View视图文件查找逻辑 之前MVC5和之前的版本中,我们要想对View文件的路径进行控制的话,则必须要对IViewEngine接口的FindPartialView或FindView方法进行重写 ...
- 从头开始学JavaScript (十)——垃圾收集
原文:从头开始学JavaScript (十)--垃圾收集 一.垃圾收集 1.1javascript垃圾收集机制: 自动垃圾收集,执行环境会负责管理代码执行过程中的使用的内存.而在C和C++之类的语言中 ...
- ios 调节器 modal 得知
代码中创建: 1.appdelegate 该contoller放置controller下一个 - (BOOL)application:(UIApplication *)application didF ...
- OCP-1Z0-051-标题决心-文章5称号
5. Which SQL statements would display the value 1890.55 as $1,890.55? (Choose three .) A. SELECT TO_ ...
- Cocos发育Visual Studio下一个HttpClient开发环境设置
Cocos2d-x 3.x相关类集成到网络通信libNetwork图书馆project于.这其中包括:HttpClient分类. 我们需要在Visual Studio溶液中加入libNetwork图书 ...
- ArcGIS网络分析之Silverlight客户端路径分析(三)
原文:ArcGIS网络分析之Silverlight客户端路径分析(三) 首先贴上最终的效果图: a.路径查询 2.最近设施点查询 3.服务区分析 说明: 1.以上的示例使用的数据是随意在ArcMap中 ...
- IOS新手教程(二)-控制流
int main(){ //2.控制流 //2.1 if语句 //1. if(expression){ } //2. if(expression){ }else{ } //3.能够有0个或是多个els ...