考试中,求答案~~~~~~~~~~~~~~~~~~~~~~~~~(在线等========)

cbxmir 2003-09-02 05:03:53
1。=======================================================第1题
#indule<studio.h>
void main()
{
int i,j,k,s;
i=0,j=10,k=2,s=0
for(;;){
i+=k
if(i>j){
printf("s=%d\n"s);
break
}
s=s+i
}
}
2。====================================================第2题
#indule<studio.h>
void main()
char*s *s1="here is"
char*s2="key";
s=s1
while(*s1)s1++
while(*s1++=*s2++)
s2=s
while(*s2)s2++
printf("%d\n"s2-s);
}


求运行结果
...全文
100 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
danceflash 2003-09-02
  • 打赏
  • 举报
回复
如果是这样:
#indule<studio.h>
void main()
{
char*s,*s1="here is";
char*s2="key";
s=s1;
while(*s1)s1++;
while(*s1++=*s2++)
s2=s;
while(*s2)s2++;
printf("%d\n",s2-s);
}
好像解不可知

但如果程序是:
#indule<studio.h>
void main()
{
char*s,*s1="here is";
char*s2="key";
s=s1;
while(*s1)s1++;
while(*s1++=*s2++);
s2=s;
while(*s2)s2++;
printf("%d\n",s2-s);
}
好像是7
fredqfc 2003-09-02
  • 打赏
  • 举报
回复
第二個好象是Segmentation fault
l1ul1u 2003-09-02
  • 打赏
  • 举报
回复
第二题程序好象有错误
char *s1="here is";
这里的s1是常量不能做s1++的;
应该这样定义的
const char *s1="here is";

danceflash 2003-09-02
  • 打赏
  • 举报
回复
第一个30
第二个怎么这么乱的说?
laorer 2003-09-02
  • 打赏
  • 举报
回复
s=30

//不过程序好像有语法错误

69,371

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧