字符移动(金山笔试题)
时间:2010-11-02 来源:铨铨灰
public class Move { public static void main(String []args) throws IOException{ Scanner sc = new Scanner(System.in); String str = sc.next(); int count = 0; char []cary = str.toCharArray(); for(int i = 0;i<cary.length;i++){ if(cary[i]=='*'){ count++; for(int j = i;j > 0;j--){ cary[j]=cary[j-1]; } cary[0] = '*'; } } for(char c :cary){ System.out.print(c); } System.out.println(); System.out.println(count); } } //结果是: //555***4444/*/***111 //*******5554444//111 //7
相关阅读 更多 +
排行榜 更多 +