几道小小的试题,请教各位了!!!

A1989050111 2009-01-13 09:29:07
5. Please write the C expression equivalent to (a-b)2+(b-d)2+|sin(x)|/(ab-2)

9. What is the running result of the following code? (5%)
#include <stdio.h>
int change(int) ;
void main()
{
int x=9;
printf("%d, %d", x, change(x));
}
int change(int i)
{
i++;
return i++;
}
10. What is the running result of the following code? (5%)
#include <stdio.h>
void changeSeason(char *);
void main()
{
char *season[]={"Spring", "Summer", "Autumn", "Winter"};
char *ps=season[0];
changeSeason(ps);
printf("Now the season is %s", ps);
}

void changeSeason(char *p)
{
p++;
++p;
}
...全文
85 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
liu_shenglun 2009-01-13
  • 打赏
  • 举报
回复
呵呵,最后一个弄错了,应该是Now the season is Spring
因为调用是只是将数组season[0]的首地址赋给形式参数指针p,而实参ps地址没变
liu_shenglun 2009-01-13
  • 打赏
  • 举报
回复
5. Please write the C expression equivalent to (a-b)2+(b-d)2+|sin(x)|/(ab-2)
答: 2*(a-b)+(b-d)*2+fabs(sin(x))/(a*b-2)
9. What is the running result of the following code? (5%)
#include <stdio.h>
int change(int) ;
void main()
{
int x=9;
printf("%d, %d", x, change(x));
}
int change(int i)
{
i++;
return i++;
}
答: 9, 10
10. What is the running result of the following code? (5%)
#include <stdio.h>
void changeSeason(char *);
void main()
{
char *season[]={"Spring", "Summer", "Autumn", "Winter"};
char *ps=season[0];
changeSeason(ps);
printf("Now the season is %s", ps);
}

void changeSeason(char *p)
{
p++;
++p;
}
答: Now the season is ring
waizqfor 2009-01-13
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 xiaoyisnail 的回复:]
5. 2*(a-b)+2*(b-d)+fabs(sin(x))/(a*b-2)
9. 9,10
10. Now the season is Spring
[/Quote]
UP了 都是基础题
Big鹏 2009-01-13
  • 打赏
  • 举报
回复

3。
now the season is Spring
Big鹏 2009-01-13
  • 打赏
  • 举报
回复

2.
结果:9,10
Big鹏 2009-01-13
  • 打赏
  • 举报
回复

(a-b)2+(b-d)2+|sin(x)|/(ab-2)
(a-b)*2+(b-d)*2+abs(sin(x))/(a*b-2);
xiaoyisnail 2009-01-13
  • 打赏
  • 举报
回复
5. 2*(a-b)+2*(b-d)+fabs(sin(x))/(a*b-2)
9. 9,10
10. Now the season is Spring
OhFish 2009-01-13
  • 打赏
  • 举报
回复
...........................
无语,我觉得你还是自己做,很基础的

69,371

社区成员

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

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