using System;
class Demo {
static String MyApplication(String str) {
char []val = str.ToCharArray();
for (int i = 0; i < str.Length; i++) {
if (i == 0 && val[i] != ' ' ||
val[i] != ' ' && val[i - 1] == ' ') {
if (val[i] >= 'a' && val[i] <= 'z') {
val[i] = (char)(val[i] - 'a' + 'A');
}
} else if (val[i] >= 'A' && val[i] <= 'Z')
val[i] = (char)(val[i] + 'a' - 'A');
}
String s = new String(val);
return s;
}
public static void Main() {
String str = "Welcome to our website!";
Console.Write(MyApplication(str));
}
}
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/265918.html