我和你
时间限制:1000 ms | 内存限制:65535 KB
难度:2
-
描述
- 将一句话中的所有的“我”换成“你”,“你”换成“我”。
-
输入
- 多组测试数据
每组给出一句中文,每段少于100个汉字
以单独一个0结束
输出 - 对于每组测试数据,输出替换后的句子。 样例输入
-
我爱你 我是中国人 1234我 0
样例输出 -
你爱我 你是中国人 1234你
- 多组测试数据
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String string = scanner.nextLine();
while (!string.equals("0")) {
string = string.replace("我", "*");
string = string.replace("你", "我");
string = string.replace("*", "你");
System.out.println(string);
string = scanner.nextLine();
}
}
}