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();
*/
* 第一个字母转大写
*/
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
- acm2026
- HDU-ACM2026
- 杭电ACM2026:首字母大写
- 杭电acm2026首字母大写
- 杭电ACM2026:首字母大写
- 杭电acm2026首字母变大写
- Manifest配置
- Android启动流程分析(三) init进程初窥
- 中文编程那些事
- python的nltk中文使用和学习资料汇总帮你入门提高
- c++面向对象的程序设计第三章
- acm2026
- SpringMVC+JPA+Mysql框架搭建
- 《Apache MINA 2.0 用户指南》第二章:基础知识
- Java中匿名类的两种实现方式
- 错误:Cannot find a valid baseurl for repo: base
- 瘦下去 (一)
- hdu 2084 数塔问题
- ARM 伪指令详解
- 【SICP练习】137 练习3.68