不难的一道题记录一下:
import java.util.Scanner;
public class Main_1051 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String s;
int N;
float temp;
while(input.hasNext()){
N = input.nextInt();
while(N>0){
s = input.next();
//startsWith()和endsWith()判断字符串是不是以特定的字符开头或结束
if(s.endsWith("F")){
s=s.replaceAll("F","");
temp=Float.parseFloat(s);
s=""+(int)(temp-32)*5/9+"C";
System.out.println(s);
}
else if(s.endsWith("C")){
s=s.replaceAll("C","");
temp=Float.parseFloat(s);
s=""+(int)(9*temp/5+32)+"F";
System.out.println(s);
}
N--;
}
}
}
}
发现自己一忙起来,就会把acm放下来……唉……