Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. package com.company;
  2. import java.util.Scanner;
  3. public class Main {
  4.  
  5. public static void main(String[] args) {
  6. Scanner sc = new Scanner (System.in);
  7. int a = 0;
  8. int sum = 0;
  9. int с = 0;
  10. String s = sc.nextLine();
  11. for (int i = 0; i < s.length() ; i++) {
  12. if ((s.charAt(i) >= '0') && (s.charAt(i) <= '9')) {
  13. while ((s.charAt(i) >= '0') && (s.charAt(i) <= '9') && (i < s.length())) {
  14. a *= 10;
  15. с = s.charAt(i) - '0';
  16. a += с;
  17. i++;
  18. }
  19. sum += a;
  20. a = 0;
  21. }
  22. }
  23. System.out.println(sum);
  24.  
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement