<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">题目连接:http://ac.jobdu.com/problem.php?pid=1510</span>
超时原因:for(i = 0; str[i]; i ++)比for(i = 0; i < strlen(str); i ++)要快
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
char str[1000000];
gets(str);
char new_str[1000000];
int i, cnt = 0;
for(i = 0; str[i]; i ++){
if(str[i] == ' '){
new_str[cnt++] = '%';
new_str[cnt++] = '2';
new_str[cnt++] = '0';
}
else new_str[cnt++] = str[i];
}
printf("%s\n",new_str);
return 0;
}