Author : Jisan
Programming language : Java
Difficulty : Easy
Status : Accepted
Problem number : UVA-12289
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=3710
Code:
import java.util.*;
public class Uva_12289{
public static void main(String args[]){
Scanner in=new Scanner(System.in);
int cases=in.nextInt();
while(cases>0){
String jisan=in.next();
int length=jisan.length();
if(length==3){
int one=0;
int two=0;
if(jisan.charAt(0)=='o'){
one++;
}
if(jisan.charAt(1)=='n'){
one++;
}
if(jisan.charAt(2)=='e'){
one++;
}
if(jisan.charAt(0)=='t'){
two++;
}
if(jisan.charAt(1)=='w'){
two++;
}
if(jisan.charAt(2)=='o'){
two++;
}
if(one>two){
System.out.println(1);
}else{
System.out.println(2);
}
}else{
System.out.println(3);
}
cases--;
}
}
}
Programming language : Java
Difficulty : Easy
Status : Accepted
Problem number : UVA-12289
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=3710
Code:
import java.util.*;
public class Uva_12289{
public static void main(String args[]){
Scanner in=new Scanner(System.in);
int cases=in.nextInt();
while(cases>0){
String jisan=in.next();
int length=jisan.length();
if(length==3){
int one=0;
int two=0;
if(jisan.charAt(0)=='o'){
one++;
}
if(jisan.charAt(1)=='n'){
one++;
}
if(jisan.charAt(2)=='e'){
one++;
}
if(jisan.charAt(0)=='t'){
two++;
}
if(jisan.charAt(1)=='w'){
two++;
}
if(jisan.charAt(2)=='o'){
two++;
}
if(one>two){
System.out.println(1);
}else{
System.out.println(2);
}
}else{
System.out.println(3);
}
cases--;
}
}
}
No comments:
Post a Comment