Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner sc = new Scanner (System.in);
- int a = 0;
- int sum = 0;
- int с = 0;
- String s = sc.nextLine();
- for (int i = 0; i < s.length() ; i++) {
- if ((s.charAt(i) >= '0') && (s.charAt(i) <= '9')) {
- while ((s.charAt(i) >= '0') && (s.charAt(i) <= '9') && (i < s.length())) {
- a *= 10;
- с = s.charAt(i) - '0';
- a += с;
- i++;
- }
- sum += a;
- a = 0;
- }
- }
- System.out.println(sum);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement