bailian 2694

时间:2014-08-10 21:11:50   收藏:0   阅读:314


#include<stdlib.h> 头文件


atof 将字符串 转化为 一个双精度值

int atof(a)

 

 


#include <stdio.h>
#include<stdlib.h>

double exp()
{ char a[20];
scanf("%s",a) ;
switch(a[0])
{
case‘+‘: return exp()+exp();
case‘-‘: return exp()-exp();
case‘*‘: return exp()*exp();
case‘/‘: return exp()/exp();
default: return atof(a);
}
}

 

void main( )
{ double ans ;
ans=exp();
printf("%f\n",ans);

}

 

 

***********************************************************************************************************

 

 

77<liqino1friend@qq.com> 17:59:04

*********************************************************
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
double ans;
double oper()
{
char a[100];
scanf("%s",a);
switch(a[0])
{
case ‘*‘: return oper()*oper();
case ‘/‘: return oper()/oper();
case ‘+‘: return oper()+oper();
case ‘-‘: return oper()-oper();
default: return atof(a);
}
}
int main()
{ ans=0;
ans=oper();
printf("%.6f\n",ans);
}

 


****************************************************************************8
[--李吉环--]<lijihuan0@qq.com> 17:59:22

 

************************************************
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<math.h>
using namespace std;
double xp()
{
char a[20];
scanf("%s",a);
switch(a[0])
{
case ‘+‘:return xp()+xp();
case ‘-‘:return xp()-xp();
case ‘*‘:return xp()*xp();
case ‘/‘:return xp()/xp();
default:return atof(a);
}
}
int main()
{
double ans;
ans=xp();
printf("%f",ans);
}

 

 

 

 

 

 

 

 

bubuko.com,布布扣

 

 

 

bubuko.com,布布扣

 

 

bubuko.com,布布扣

 

 

bubuko.com,布布扣

bailian 2694,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!