HDOJ 1170 Balloon Comes!

#include <stdio.h>

int
main()
{
      int t;
      int a,b;
      char s;
      scanf("%d", &t);
      while(t--){
          getchar();
          scanf("%c %d %d", &s, &a, &b);
          if(s=='+')printf("%d", a+b);
          else if(s=='-')printf("%d", a-b);
          else if(s=='*')printf("%d", a*b);
          else if(s=='/'){
               if(a%b!=0)
               printf("%.2lf", (double)a/b);
               else
               printf("%d", a/b);
          }
          printf("\n");
      }
      return 0;
}

你可能感兴趣的:(HDOJ 1170 Balloon Comes!)