字符串替换
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 8497 | Accepted: 4012 |
Description
编写一个C程序实现将字符串中的所有"you"替换成"we"
Input
输入包含多行数据
每行数据是一个字符串,长度不超过1000
数据以EOF结束
每行数据是一个字符串,长度不超过1000
数据以EOF结束
Output
对于输入的每一行,输出替换后的字符串
Sample Input
you are what you do
Sample Output
we are what we do
Source
代码:
import java.util.Scanner;
public class Main {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input=new Scanner(System.in);
while(input.hasNext()){
String str=input.nextLine();
System.out.println(str.replaceAll("you", "we"));
}
}
}