Maintenant que j'ai terminé mon étude de Java-Silver, j'ai essayé "AtCoder Problem" qui peut sortir gratuitement. Je vais laisser un mémorandum sur Qiita!
L'énoncé du problème étant long, veuillez ici
TorT.java
import java.util.Scanner;
public class WindObservation {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
double wind_direction = sc.nextInt();
wind_direction = wind_direction / 10;
double Wind = sc.nextInt();
Wind = Wind / 60;
Wind = ((double)Math.round(Wind * 10))/10;
System.out.println(Direction(wind_direction));
System.out.println(Amount(Wind));
}
public static String Direction(double direction){
String master = "";
if((11.25 <= direction) && (direction < 33.75)){
master = "N";
}else if((33.75 <= direction) && (direction < 56.25)){
master = "NE";
}else if((56.25 <= direction) && (direction < 78.75)){
master = "ENE";
}else if((78.75 <= direction) && (direction < 101.25)){
master = "E";
}else if((101.25 <= direction) && (direction < 123.75)){
master = "ESE";
}else if((123.75 <= direction) && (direction < 146.25)){
master = "SE";
}else if((146.25 <= direction) && (direction < 168.75)){
master = "SSE";
}else if((168.75 <= direction) && (direction < 191.25)){
master = "S";
}else if((191.25 <= direction) && (direction < 213.75)){
master = "SSW";
}else if((213.75 <= direction) && (direction < 236.25)){
master = "SW";
}else if((236.25 <= direction) && (direction < 258.75)){
master = "WSW";
}else if((258.75 <= direction) && (direction < 281.25)){
master = "W";
}else if((281.25 <= direction) && (direction < 303.75)){
master = "WNW";
}else if((303.75 <= direction) && (direction < 326.25)){
master = "NW";
}else if((326.25 <= direction) && (direction < 348.75)){
master = "NNW";
}else{
master = "N";
}
return master;
}
public static int Amount(double wind){
int i = 0;
if((0.0 <= wind) && (wind < 0.2)){
i = 0;
}else if((0.3 <= wind) && (wind < 1.5)){
i = 1;
}else if((1.6 <= wind) && (wind < 3.3)){
i = 2;
}else if((3.4 <= wind) && (wind < 5.4)){
i = 3;
}else if((5.5 <= wind) && (wind < 7.9)){
i = 4;
}else if((8.0 <= wind) && (wind < 10.7)){
i = 5;
}else if((10.8 <= wind) && (wind < 13.8)){
i = 6;
}else if((13.9 <= wind) && (wind < 17.1)){
i = 7;
}else if((17.2 <= wind) && (wind < 20.7)){
i = 8;
}else if((20.8 <= wind) && (wind < 24.4)){
i = 9;
}else if((24.5 <= wind) && (wind < 28.4)){
i = 10;
}else if((28.5 <= wind) && (wind < 32.6)){
i = 11;
}else{
i = 12;
}
return i ;
}
}
Veuillez me pardonner que le code est fastidieux et que les noms de variables sont désordonnés. Je voudrais écrire le code original de l'esprit que «je devrais bouger d'abord» et améliorer la qualité du code à partir de maintenant.
$ java WindObservation
> 2750
> 628
W
5
$ java WindObservation
> 1687
> 1029
SSE
8
Cela fonctionne, donc c'est sûr! !! !!
Je vais le sortir avec AtCoder Problem pendant un moment. Quand Corona se calme, j'aimerais prendre Java-Silver et défier Gold.
Recommended Posts