[字符串与数组] Q:Write a method to replace all spaces in a string with ‘%20’ 题目:写一个算法将一个字符串中的空格替换成%20 解答: 很直观的解法,首先统计出字符串中空格个数,然后分配新的内存空间,依次从头到尾复制原字符串到新字符串中,遇到空格,则复制%20这三个字符.还有没有其他更好点的方法呢?? char* replace(char* str){ int len=strlen(str); int spaceNum=0; int…
可对照查看网盘ASCII表http://yunpan.cn/cyxg4wQjQaGEQ (提取码:8b29) public static void main(String[] args) { // // TODO Auto-generated method stub int a=001; int b=32;//制表符 int c=13;//回车键 char character = (char)a; char cb = (char)b; String line ="niaho" + ch…