Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void main() {
- myFunc("99946");
- }
- void myFunc(String data) {
- bool isOdd = false;
- String result = "";
- for (var x in data.split("")) {
- if (int.parse(x) % 2 == 0 && !isOdd) {
- result += "*" + x;
- } else if (int.parse(x) % 2 != 0 && isOdd) {
- result += "-" + x;
- } else {
- result += x;
- }
- if (int.parse(x) % 2 == 0) {
- isOdd = false;
- } else {
- isOdd = true;
- }
- }
- print("result $result");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement