zoukankan      html  css  js  c++  java
  • 程序


    #include "stdio.h"
    #include "stdlib.h"
    #include "ctype.h"
    int n=0;
    char record[20];
    float product();
    float change();
    float muli()
    {
    float summ;
    summ=product();
    while(record[n]=='-'||record[n]=='+')
    {
    switch(record[n])
    {
    case '+':n++;summ+=product();break;
    case '-':n++;summ-=product();break;
    }
    }
    return summ;
    }
    float product()
    {
    float sump;
    sump=change();
    while(record[n]=='*'||record[n]=='/')
    {
    switch(record[n])
    {
    case '*':n++;sump*=change();break;
    case '/':n++;sump/=change();break;
    }
    }
    return sump;
    }
    float change()
    {
    float sumc;
    char rec[20],i=0;
    if(record[n]=='(')
    {
    n++;
    sumc=muli();
    }
    if(record[n]==')')
    n++;
    while(isdigit(record[n])||record[n]=='.')
    {
    while(isdigit(record[n])||record[n]=='.')
    rec[i++]=record[n++];
    rec[i]='\0';
    sumc=atof(rec);
    }
    return sumc;
    }
    void main()
    {
    while(1)
    {
    n=0;
    scanf("%s",record);
    printf("%s=%g\n",record,muli());
    }
    }

  • 相关阅读:
    mysql的复制
    web页面请求历程
    django工作原理简介
    http协议
    路由器和交换机的区别
    OSI七层模型
    TCP/IP协议总结
    IO复用
    僵尸进程和孤儿进程
    java源代码如何打成jar包
  • 原文地址:https://www.cnblogs.com/lx1502720102/p/6550051.html
Copyright © 2011-2022 走看看