zoukankan      html  css  js  c++  java
  • hdu 1237

    #include<stdio.h>
    #include<string.h>
    int main() {
     double a;
     double b;
     int c;
     char ch;
     double num[300];
     while(scanf("%d",&c)) {
          if(getchar()==' '&&c==0)//注意必须这样写
        break;
      int i=0;
      num[0]=c;
      while(1) {
       scanf("%c%lf",&ch,&b);
       if(ch=='/')
        num[i]/=b;
       else
        if(ch=='*')
         num[i]*=b;
        else
         if(ch=='+')
          num[++i]=b;
         else
          num[++i]=-b;
         if(getchar()==' ')
          break;
      } 
      a=0;
      for(int j=0;j<=i;j++)
       a+=num[j];
      printf("%.2f ",a);
     }
     return 0;
    }


     

  • 相关阅读:
    设计模式第一次练习
    区间最大数
    魔方数
    螺旋数
    回文串
    最长单词
    指针的应用之学生成绩
    赛马
    突击队任务
    贪婪之骑士
  • 原文地址:https://www.cnblogs.com/thefirstfeeling/p/4411009.html
Copyright © 2011-2022 走看看