[java]代码库
import java.util.*;
public class Main{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
String s = scan.nextLine();
String cs = scan.next();
char c = cs.charAt(0);
String str = scan.next();
int i, count = 0;
for(i = 0; i < s.length(); i++) {
if(s.charAt(i) == c){
count++;
}
}
System.out.println(count);
for(i = s.length()-1; i >= 0; i--) {
System.out.print(s.charAt(i));
}
System.out.println();
i = 0;
int index = s.indexOf(str);
while(index != -1) {
if(i == 0)
System.out.print(index);
else
System.out.print(" "+index);
i = index + str.length();
index = s.indexOf(str, i);
}
System.out.println();
StringBuffer sb = new StringBuffer(s) ;
int fromIndex = 0; //第一个单词首字母位置
do {
sb.replace(fromIndex, fromIndex+1, sb.substring(fromIndex, fromIndex+1).toUpperCase());
} while ( (fromIndex = sb.indexOf(" ", fromIndex)+1) != 0);
System.out.println(sb);
scan.close();
}
}