数据结构与算法之Stack(栈)的应用——用stack实现一个计算器-/bin/calc.dart

时间:2022-02-08 15:10:27

计算器的bin/calc.dart 可执行代码:

 import 'dart:io';
import 'package:data_struct/stack/sample/calculator.dart'; void main() {
print('please input the expression:');
var ins = stdin.readLineSync();
while (ins != 'exit') {
try {
var r = calc(ins);
print('\n the result is: $r');
} on FormatException {
print('Format error!');
} on Exception catch (e) {
print('Unknown error: $e!');
} print('\nplease input the expression:');
ins = stdin.readLineSync();
}
}

相关文章