Author : Jisan
Programming language : Java
Difficulty : Easy
Status : Accepted
Problem number : UVA-494
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=435
Code:
import java.util.Scanner;
public class Uva__494 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
while (in.hasNext()) {
String s = in.nextLine();
boolean jisan = false;
int count = 0;
for (char c : s.toCharArray()) {
if (Character.isLetter(c)) {
if (!jisan) {
jisan = true;
count++;
}
} else{
jisan = false;
}
}
System.out.println(count);
}
}
}
Programming language : Java
Difficulty : Easy
Status : Accepted
Problem number : UVA-494
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=435
Code:
import java.util.Scanner;
public class Uva__494 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
while (in.hasNext()) {
String s = in.nextLine();
boolean jisan = false;
int count = 0;
for (char c : s.toCharArray()) {
if (Character.isLetter(c)) {
if (!jisan) {
jisan = true;
count++;
}
} else{
jisan = false;
}
}
System.out.println(count);
}
}
}
No comments:
Post a Comment