
【程序】
#include
main()
{
int i, j;
char ch, *p1, *p2, *s[4]={"four","hello","peak","apple"};
for(i = 0; i < 4; i++){
p1 = p2 = s[i];
ch = *(p1 + i);
while(*p1 != '\0'){
if(*p1 != ch){
*p2 = *p1;
p2++;
}
p1++;
}
*p2 = '\0';
}
for(i = 0; i < 4; i++)
printf("%s\n", s[i]);
}
【问题】
(21) 程序运行时,第1行输出 (21) 。
A、our B、four C、fur D、fou
(22) 程序运行时,第2行输出 (22) 。
A、ello B、hllo C、heo D、hell
(23) 程序运行时,第3行输出 (23) 。
A、peak B、eak C、pek D、pak
(24) 程序运行时,第4行输出 (24) 。
A、pple B、apple C、ale D、appe
说的清楚点,别只给我个答案好不。我看懂解释了我就追加分数
此函数为将字符串指针数组s[i] 中,将各个字符串指针指向的字符串中除了与它当中第i个字符不相等的所早圆有橘睁槐字符顺序输出圆友,如对于 *s[0] = "four", ch='f', 故输出 our
*s[1] = "hello", ch='e', 故输出 hllo
因此输出结果依次为 A B C D
经VC运行,答案应该为 A B C D