1 / 3

作业下载 ccea.zju/clearn/

第 3 章作业. 作业下载 http://www.ccea.zju.edu.cn/clearn/. 交作业信箱 0076060@fa.zju.edu.cn. 作业只需交答案. 1. 假定所有变量均已正确定义,下列程序段运行后 y 的值是( )。 int a=10, y=10; if (a=0) y=y-1; else if(a>0)y=y+1;else y=y+y; A. 20 B. 11 C. 9 D. 0. 2. 下面的程序片段所表示的数学函数关系是( )。 y=-1;

uma-ashley
Download Presentation

作业下载 ccea.zju/clearn/

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 第3章作业 作业下载 http://www.ccea.zju.edu.cn/clearn/ 交作业信箱 0076060@fa.zju.edu.cn 作业只需交答案 1.假定所有变量均已正确定义,下列程序段运行后y的值是( )。 int a=10, y=10; if (a=0) y=y-1; else if(a>0)y=y+1;else y=y+y; A. 20 B. 11 C. 9 D. 0 2.下面的程序片段所表示的数学函数关系是( )。 y=-1; if(x!=0) if(x>0) y=1; else y=0; -1 (x<0) 1 (x<0) 0 (x<0) -1 (x<0) A. y= 0 (x=0) B. y= -1 (x=0) C. y= -1 (x=0) D. y= 1 (x=0) 1 (x>0) 0 (x>0) 1 (x>0) 0 (x>0

  2. 3. int i,a,b,c; for(i=0;i<a;i=i+1) switch(b) { case 1: if(c+i==5)printf("%c",'x'); else printf("%c",'y'); break; case 2: if(c+i<10)printf("%c",'y'); else printf("%c",'x'); break; default: printf("%c",'x'); } 问:(1)上述程序若要输出yyx, a,b,c的初值应为_________ (2)上述程序若要输出xy, a,b,c的初值应为_________

  3. 4.输入年year、月month和日day,计算该年的第几天。4.输入年year、月month和日day,计算该年的第几天。 void main() { int year,month,day,leap;scanf(“%d%d%d”,&year,&month,&day); leap=(____(1)______||year%400==0); switch(month){ case 12: day+=30; case 11: day+=31; case 10: day+=30; case 9: day+= (2) ; case 8: day+=31; case 7: day+=30; case 6: day+=31; case 5: day+=30; case 4: day+=31; case 3: day+= (3) ; case 2: day+=31; } printf("%d",day);}

More Related