View difference between Paste ID: 5W3DSgpF and
SHOW:
|
|
- or go back to the newest paste.
1 | - | |
1 | + | import fiji.io.*; |
2 | class ContaParole { | |
3 | ||
4 | public static int parole(String s) { | |
5 | int contparole; | |
6 | boolean lettera; | |
7 | int i; | |
8 | int l; | |
9 | char c = ' '; | |
10 | contparole = 0; | |
11 | lettera = true; | |
12 | i = 0; | |
13 | l = s.length() - 1; | |
14 | ||
15 | while ( l >= 0 ) { | |
16 | ||
17 | if (s.charAt(i) ==c ){ | |
18 | l--; | |
19 | contparole ++; | |
20 | }else{ | |
21 | i++; | |
22 | contparole = 0; | |
23 | l--; | |
24 | } | |
25 | } | |
26 | return contparole; | |
27 | } | |
28 | ||
29 | public static void main(String[] args) { | |
30 | String s; | |
31 | int contparole; | |
32 | ||
33 | System.out.println("Scrivi una frase:"); | |
34 | s = Lettore.in.leggiLinea(); | |
35 | ||
36 | contparole = ContaParole.parole(s); | |
37 | System.out.println(contparole); | |
38 | } | |
39 | } |