2016HUAS暑假集训训练题 F - 简单计算器
Description
Input
Output
Sample Input
Sample Output
#include <stdio.h>
#include<string.h>
int main()
{
int t,l ;double sum;double num[200];
while(scanf("%d",&t))
{
l=0;
sum = t*1.0;
char c;if(t==0&&(c = getchar())=='\n')return 0;
while((c = getchar())!='\n')
{ if(c=='*') { scanf("%d",&t);sum*=t;} //算出含*的值
if(c=='/') { scanf("%d",&t);sum/=t*1.0;} // 算出含/的值
if(c=='+')
{
num[l++] =sum; scanf("%d",&t);sum = t*1.0; //把sum存入数组
}
if(c == '-')
{
num[l++] = sum; scanf("%d",&t);sum = -t*1.0;//把sum存入数组
}
}
num[l++] = sum;
double sun = 0;
for(int i = 0; i < l;i++) 对sum求和 算出表达式的值
sun += num[i];
printf("%.2lf\n",sun);
}
}
2016HUAS暑假集训训练题 F - 简单计算器的更多相关文章
- 2016HUAS暑假集训训练题 G - Oil Deposits
Description The GeoSurvComp geologic survey company is responsible for detecting underground oil dep ...
- 2016huas暑假集训训练题 G-Who's in the Middle
题目链接:http://acm.hust.edu.cn/vjudge/contest/121192#problem/G 此题大意是给定一个数n 然后有n个数 要求求出其中位数 刚开始以为是按数学中的 ...
- 2016HUAS暑假集训训练2 F - A Simple Problem with Integers
Description 给出了一个序列,你需要处理如下两种询问. "C a b c"表示给[a, b]区间中的值全部增加c (-10000 ≤ c ≤ 10000). " ...
- 2016HUAS暑假集训训练题 D - Find a way
F ...
- 2016HUAS暑假集训训练题 E - Rails
There is a famous railway station in PopPush City. Country there is incredibly hilly. The station wa ...
- 2016HUAS暑假集训训练题 B - Catch That Cow
B - Catch That Cow Description Farmer John has been informed of the location of a fugitive cow and w ...
- 2016huasacm暑假集训训练三 F - Jungle Roads
题目链接:http://acm.hust.edu.cn/vjudge/contest/123674#problem/F 题意:在相通n个岛屿的所有桥都坏了,要重修,重修每一个桥所用的时间不同,求重修使 ...
- 2016huasacm暑假集训训练五 F - Monkey Banana Problem
题目链接:http://acm.hust.edu.cn/vjudge/contest/126708#problem/F 题意:求至上而下一条路径的所经过的值得和最大值,这题比赛时就出了 但当时看不懂题 ...
- 2016HUAS暑假集训训练2 O - Can you find it?
题目链接:http://acm.hust.edu.cn/vjudge/contest/121192#problem/O 这道题是一道典型二分搜素题,题意是给定3个数组 每个数组的数有m个 再给定l个s ...
随机推荐
- UVA 11987 Almost Union-Find (并查集+删边)
开始给你n个集合,m种操作,初始集合:{1}, {2}, {3}, … , {n} 操作有三种: 1 xx1 yy1 : 合并xx1与yy1两个集合 2 xx1 yy1 :将xx1元素分离出来合到yy ...
- ASP.Net MVC开发基础学习笔记(2):HtmlHelper与扩展方法
一.一个功能强大的页面开发辅助类—HtmlHelper初步了解 1.1 有失必有得 在ASP.Net MVC中微软并没有提供类似服务器端控件那种开发方式,毕竟微软的MVC就是传统的请求处理响应的回归. ...
- 《DSP using MATLAB》 示例Example4.1
今天开始看第4章,从开始看这本书到现在,过去一个多月,收获不少,继续坚持.
- hive :MetaException(message:Version information not found in metastore. )
MetaException(message:Version information not found in metastore. ) Hive now records the schema vers ...
- BZOJ 1925[Sdoi2010]地精部落 题解
题目大意: 1~n的排列中,要任意一个数要么比它左右的数都大或小,求所有的方案数. 思路: 主要思路:离散. 三个引理: ①在n->n-1的转化过程中,我们删除了一个点后,我们可以将n-1个点视 ...
- android 百度地图 通过剪裁图片添加 Marker
初始化百度地图: private void initViews() { mMapView = (MapView) findViewById(R.id.bmapView); mBaiduMap = mM ...
- ACM 兄弟郊游问题
兄弟郊游问题 时间限制:3000 ms | 内存限制:65535 KB 难度:2 描述 兄弟俩骑车郊游,弟弟先出发,每分钟X米,M分钟后,哥哥带一条狗出发.以每分钟Y米的速度去追弟弟,而狗则以 ...
- 洛谷 P1092 虫食算 Label:dfs
题目描述 所谓虫食算,就是原先的算式中有一部分被虫子啃掉了,需要我们根据剩下的数字来判定被啃掉的字母.来看一个简单的例子: 43#9865#045 +8468#6633 44445509678 其中# ...
- 洛谷 P1379 八数码难题 Label:判重&&bfs
特别声明:紫书上抄来的代码,详见P198 题目描述 在3×3的棋盘上,摆有八个棋子,每个棋子上标有1至8的某一数字.棋盘中留有一个空格,空格用0来表示.空格周围的棋子可以移到空格中.要求解的问题是:给 ...
- 【JAVA】Quartz中时间表达式的设置
Quartz中时间表达式的设置-----corn表达式 时间格式: <!-- s m h d m w(?) y(?) -->, 分别对应: 秒>分>小时>日>月 ...