首页 > 解决方案 > 未处理的异常:FormatException:无效的 radix-10 数字(在字符 1 处)12 2 5.30

问题描述

我正在尝试解决 URI 在线判断问题编号 1010 中的问题。在我的 IDE 中运行代码不会引发错误。但是,它会在 URI 中引发运行时错误。

12 2 5.30
^

#0      int._throwFormatException (dart:core-patch/integers_patch.dart:131)
#1      int._parseRadix (dart:core-patch/integers_patch.dart:142)
#2      int._parse (dart:core-patch/integers_patch.dart:100)
#3      int.parse (dart:core-patch/integers_patch.dart:63)
#4      main (file:///judge/judge-7457cda102c440638d0db570b8eed561.d/Main.dart:7)
#5      _startIsolate. (dart:isolate-patch/isolate_patch.dart:301)
#6      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168)

这是我的代码

import 'dart:io';

void main() {
  int a, b;
  double c, result;

  a = int.parse(stdin.readLineSync()!);
  b = int.parse(stdin.readLineSync()!);
  c = double.parse(stdin.readLineSync()!);
  result = b * c;

  a = int.parse(stdin.readLineSync()!);
  b = int.parse(stdin.readLineSync()!);
  c = double.parse(stdin.readLineSync()!);
  result += b * c;
  String pagar = result.toStringAsFixed(2);

  print('VALOR A PAGAR: R\$ $pagar');
}

提前告诉大家。

标签: dartunhandled-exceptionformatexception

解决方案


推荐阅读