fork(6) download
  1. import java.util.Scanner;
  2.  
  3. class Ideone {
  4.  
  5. public static void main(String[] args) {
  6.  
  7. try {
  8. Scanner odczyt = new Scanner(System.in);
  9. ;
  10. while (odczyt.hasNextLine()) {
  11. int numberword = 0;
  12. int numbernumber = 0;
  13.  
  14. String zdanie = odczyt.nextLine();
  15. String[] podzdania = zdanie.split(" ");
  16. boolean exception = false;
  17.  
  18. int wszytsko = podzdania.length;
  19.  
  20.  
  21. for (int i = 0; i < podzdania.length; i++) {
  22. try {
  23. Integer.parseInt(podzdania[i]);
  24. } catch (NumberFormatException e) {
  25. numberword++;
  26. }
  27. }
  28. numbernumber = wszytsko - numberword;
  29. System.out.println(numbernumber + " " + numberword);
  30.  
  31. }
  32.  
  33. } catch (Exception e) {
  34.  
  35. }
  36.  
  37. }
  38.  
  39. }
  40.  
Success #stdin #stdout 0.12s 29296KB
stdin
Romek ma 2 koty i 3 psy
2 plus 2 jest rowne 4
stdout
2 5
3 3