Compile Error

foo.cc:10:7: warning: character constant too long for its type
   10 |  case 'a=500' :
      |       ^~~~~~~
foo.cc: In function 'int main()':
foo.cc:7:10: warning: format '%f' expects argument of type 'float*', but argument 2 has type 'int*' [-Wformat=]
    7 |  scanf("%f,%f,%f",&a);
      |         ~^        ~~
      |          |        |
      |          float*   int*
      |         %d
foo.cc:7:13: warning: format '%f' expects a matching 'float*' argument [-Wformat=]
    7 |  scanf("%f,%f,%f",&a);
      |            ~^
      |             |
      |             float*
foo.cc:7:16: warning: format '%f' expects a matching 'float*' argument [-Wformat=]
    7 |  scanf("%f,%f,%f",&a);
      |               ~^
      |                |
      |                float*
foo.cc:13:9: error: the value of 'a' is not usable in a constant expression
   13 |  case a>500 :
      |         ^~~
foo.cc:6:6: note: 'int a' is not const
    6 |  int a;
      |      ^
foo.cc:13:9: error: the value of 'a' is not usable in a constant expression
   13 |  case a>500 :
      |         ^~~
foo.cc:6:6: note: 'int a' is not const
    6 |  int a;
      |      ^
foo.cc:16:8: error: expression '(a = 1000)' is not a constant expression
   16 |  case a=1000 :
      |       ~^~~~~
foo.cc:16:9: error: modification of 'a' is not a constant expression
   16 |  case a=1000 :
      |         ^~~~
foo.cc:19:9: error: the value of 'a' is not usable in a constant expression
   19 |  case a>1000 :
      |         ^~~~
foo.cc:6:6: note: 'int a' is not const
    6 |  int a;
      |      ^
foo.cc:19:9: error: the value of 'a' is not usable in a constant expression
   19 |  case a>1000 :
      |         ^~~~
foo.cc:6:6: note: 'int a' is not const
    6 |  int a;
      |      ^
foo.cc:22:8: error: expression '(a = 1500)' is not a constant expression
   22 |  case a=1500 :
      |       ~^~~~~
foo.cc:22:9: error: modification of 'a' is not a constant expression
   22 |  case a=1500 :
      |         ^~~~
foo.cc:25:10: error: the value of 'a' is not usable in a constant expression
   25 |   case a>1500 :
      |          ^~~~
foo.cc:6:6: note: 'int a' is not const
    6 |  int a;
      |      ^
foo.cc:25:10: error: the value of 'a' is not usable in a constant expression
   25 |   case a>1500 :
      |          ^~~~
foo.cc:6:6: note: 'int a' is not const
    6 |  int a;
      |      ^
foo.cc:28:9: error: expression '(a = 2000)' is not a constant expression
   28 |   case a=2000 :
      |        ~^~~~~
foo.cc:28:10: error: modification of 'a' is not a constant expression
   28 |   case a=2000 :
      |          ^~~~
foo.cc:31:10: error: the value of 'a' is not usable in a constant expression
   31 |   case a>2000 :
      |          ^~~~
foo.cc:6:6: note: 'int a' is not const
    6 |  int a;
      |      ^
foo.cc:31:10: error: the value of 'a' is not usable in a constant expression
   31 |   case a>2000 :
      |          ^~~~
foo.cc:6:6: note: 'int a' is not const
    6 |  int a;
      |      ^
foo.cc:35:13: warning: format '%f' expects argument of type 'double', but argument 2 has type 'int' [-Wformat=]
   35 |  printf("%.2f",a);
      |          ~~~^  ~
      |             |  |
      |             |  int
      |             double
      |          %.2d
foo.cc:7:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    7 |  scanf("%f,%f,%f",&a);
      |  ~~~~~^~~~~~~~~~~~~~~
[Hydro](https://hydro.ac)提供评测服务

信息

递交者
类型
递交
题目
P1026 超市促销活动
语言
C++
递交时间
2021-12-11 09:01:40
评测时间
2021-12-11 09:01:40
评测机
分数
0
总耗时
0ms
峰值内存
0 Bytes