acm2026

来源:互联网 发布:战舰世界长门数据 编辑:程序博客网 时间:2024/06/05 18:32
/**
 * 第一个字母转大写
 */
import java.util.*;


public class acm2026 {


public static void main(String[] args) {
Scanner in = new Scanner(System.in);
while (in.hasNext()) {
String str = in.nextLine();
char[] c = new char[1];
String[] a = str.split(" ");
for (int i = 0; i < a.length; i++) {
c[0] = a[i].charAt(0);
String tp = new String(c);
/*
* replaceFirst(String regex, String replacement) 使用给定的
* replacement 替换此字符串匹配给定的正则表达式的第一个子字符串。
*/
if (i != a.length - 1)
System.out.print(a[i].replaceFirst(tp, tp.toUpperCase())
+ " ");
else
System.out.println(a[i].replaceFirst(tp, tp.toUpperCase()));
}


}
}
}


/*
 * for(int i=0; i<a.length-1; i++) { c[0] = a[i].charAt(0); String tp = new
 * String(c); System.out.print(a[i].replaceFirst(tp, tp.toUpperCase()) + " "); }
 * c[0] = a[a.length-1].charAt(0); String tp = new String(c);
 * System.out.print(a[a.length-1].replaceFirst(tp, tp.toUpperCase()));
 * System.out.println();
 */
0 0
原创粉丝点击