标签:algorithm vector style otto 用例 har mem desc turn
# include <stdio.h> # include <string.h> # include <stdlib.h> # include <iostream> # include <fstream> # include <vector> # include <queue> # include <stack> # include <map> # include <math.h> # include <algorithm> using namespace std; # define pi acos(-1.0) # define mem(a,b) memset(a,b,sizeof(a)) # define FOR(i,a,n) for(int i=a; i<=n; ++i) # define For(i,n,a) for(int i=n; i>=a; --i) # define FO(i,a,n) for(int i=a; i<n; ++i) # define Fo(i,n,a) for(int i=n; i>a ;--i) typedef long long LL; typedef unsigned long long ULL; int main() { double num[205],n; char f; while(cin>>n) { mem(num,0); int sum=0; num[0]=n; if(getchar()==‘\n‘&&n==0)break;//cin忽略输入数据之前空格,但是后面的空格使用getchar忽略,同时可以判断是否换行结束 while(1) { cin>>f>>n; if(f==‘*‘)num[sum]*=n; else if(f==‘/‘)num[sum]/=n; else if(f==‘+‘)num[++sum]=n; else num[++sum]=-n; if(getchar()==‘\n‘)break; } n=0; for(int i=0;i<=sum;i++) n+=num[i]; printf("%.2lf\n",n); } return 0; }
标签:algorithm vector style otto 用例 har mem desc turn
原文地址:http://www.cnblogs.com/teble/p/7193618.html