网站大量收购独家精品文档,联系QQ:2885784924

c条件表达式与选择降尼构.ppt

  1. 1、本文档共31页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
c条件表达式与选择降尼构

#includestdio.h void main() { int a,b,max; printf(\n input two numbers: ); scanf(%d%d,a,b); max=a; if (maxb) max=b; printf(max=%d,max); } 例:求两个整数的较大值。 max=ab? a: b; Evaluation only. Created with Aspose.Slides for .NET 3.5 Client Profile 5.2.0.0. Copyright 2004-2011 Aspose Pty Ltd. #includestdio.h void main( ) { int x,y; scanf(%d,x); if (x0) y=-x; else y= x; printf(x=%-6d,y=%d,x,y); } 例:求任意整数的绝对值。 y= x=0? x: -x; Evaluation only. Created with Aspose.Slides for .NET 3.5 Client Profile 5.2.0.0. Copyright 2004-2011 Aspose Pty Ltd. #include stdio.h void main() { int a=5,b=8,z; z= (a++b++) ? a++ : b++; printf(a=%d,b=%d,z=%d\n,a,b,z); } Evaluation only. Created with Aspose.Slides for .NET 3.5 Client Profile 5.2.0.0. Copyright 2004-2011 Aspose Pty Ltd. #includestdio.h void main( ) { int x, leap; scanf(%d,x); leap=0; if (x%4==0 x%100!=0 || x%400==0) leap=1; if (leap) printf(%d is ,x); else printf(%d isnt ,x); printf(a leap.); } 例:判断某年是否为闰年。 Evaluation only. Created with Aspose.Slides for .NET 3.5 Client Profile 5.2.0.0. Copyright 2004-2011 Aspose Pty Ltd. #includestdio.h void main( ) { char c; printf(input a character: ); c=getchar(); if (c32) printf(This is a control character\n); else if (c=0 c=9) printf(This is a digit\n); else if (c=A c=Z) printf(This is a capital letter\n); else if (c=a c=z) printf(This is a small letter\n); else printf(This is an other character\n); } 例:判断输入的字符的类别。 Evaluation only. Created with Aspose.Slides for .NET 3.5 Client Profile 5.2.0.0. Copyright 2004-2011 Aspose Pty Ltd. 练习: 输入一个数,判别它是否能被3整除;若能,打印YES,不能,打印NO。 练习: 编写程序,根据输入的学生成绩,给出相应的等级。90分以上的等级为A,60分以下的等级为E,其余每10分为一个等级。 练习:输入一个0-6的整数,转换成星期输出。 Evaluation only. Created with Aspose.Slides for .NET 3.5 Client Profile 5.2.0.0. Copyright

文档评论(0)

ayangjiayu3 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档