又是一道水体

原题叙述如下

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 50108    Accepted Submission(s): 27703


Problem Description
输入一个英文句子,将每个单词的第一个字母改成大写字母。
 

 

Input
输入数据包含多个测试实例,每个测试实例是一个长度不超过100的英文句子,占一行。
 

 

Output
请输出按照要求改写后的英文句子。
 

 

Sample Input
i like acm i want to get an accepted
 

 

Sample Output
I Like Acm I Want To Get An Accepted
 

 

Author
lcy
 
java语言实现如下
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		 Scanner scan =new Scanner(System.in);
			while(scan.hasNext()){
				String a=scan.nextLine();
				String upStr = a.toUpperCase();
				char s[]=a.toCharArray();
				s[0]=upStr.charAt(0);
				for(int i=1;i<s.length;i++){
					if(s[i-1]==' '){
						s[i]=upStr.charAt(i);
                }	
            }
				System.out.println(s);
        }    	
    }
}

  

 

相关文章:

  • 2021-06-04
  • 2021-07-10
  • 2021-11-25
  • 2022-12-23
  • 2021-10-18
  • 2021-08-28
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-09-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-20
  • 2022-12-23
相关资源
相似解决方案