C程序设计源代码大全.docx

  1. 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
  2. 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  3. 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
S2_1 #includeiostream using namespace std; void main() { float a,b,c; coutinput a b c\n; cinabc; if((a+bc)||(b+ca)||(a+cb)) coutNot Triangle\n; else coutTriangle\n; } S2_2 #includeiostream using namespace std; void main() { int year; coutInput year: ; cinyear; if((year%4==0year%100!=0)||(year% 400==0)) coutyear is a leap year\n; else coutyear is not a leap year\n; } S2_3 #includeiostream using namespace std; void main() { float a1, a2; char oper; float result; int flag=0; cout请输入简单的运算式:\n; cina1opera2; switch(oper) { case+: result=a1+a2; break; case-: result=a1-a2; break; case*: result=a1*a2; break; default: cout输入错误的运算符!\n; flag=1; } if(flag==0) couta1opera2=resulten dl; } S2_4 #includeiostream #includemath.h using namespace std; void main() { float a,b,c,x1,x2; cout请输入方程的 3 个系数 a b c \n; cinabc; x1=(-b+sqrt(b*b-4*a*c))/2*a; x2=(-b-sqrt(b*b-4*a*c))/2*a; if(b*b-4*a*c0) cout无实根!\n; else coutx1=x1endl; coutx2=x2endl; } S3_1 #includeiostream using namespace std; void main() { int x,y; for(x=1;x=30;x++) for(y=1;y=30;y++) if(x+y==302*x+4*y==90) cout鸡有 1 x\n兔有yendl; } S3_2 #includeiostream.h void main() { int a0,a1,a2; int b; for(a2=1;a2=9;a2++) for(a1=1;a1=9;a1++) for(a0=1;a0=9;a0++) { b=100*a2+10*a1+a0; if(b==a2*a2*a2+a1*a1*a1+a0*a0*a0) coutbendl; } } S3_3 #includeiostream.h void main() { int a0,a1,a2; int b; for(b=100;b=999;b++) { a2=b/100; a1=(b/10)%10; a0=b%10; if(b==a0*a0*a0+a1*a1*a1+a2*a2*a2) coutb\t; } } S3_4 #includeiostream.h void main() { } } int a,b,c; for(a=1;a=36;a++) for(b=1;b=36;b++) for(c=1;c=36;c++) if(a+b+c==36a*4+b*2+c/2==36c %2==0) cout男人a\n女人b\n小孩cendl; } S3_5_1 #includeiostream.h void main() { int a; for(a=1;a=599;a++) { if((a%10==5||(a/10)%10==5||(a/10/10)% 10==5)(a%3==0)) coutaendl; } S3_5_2 #includeiostream.h void main() { int a,b,c=0; cout请输入整数:; cina; while(a) { b=a%10; c=c+b; a=a/10;} coutcendl; } S4_1 #includeiostream.h void main() } } { int a,b; int x,t; cout请输入两个正整数:; cinab; x=a*b; if(ab) { t=a;a=b;b=t;} while(t=a%b) { a=b; b=t; } cout最大公约数

文档评论(0)

文章写作专家 + 关注
官方认证
服务提供商

本司主营文章撰写、培训教材、合同协议、发言稿、策划、汇报、各类文案。 ~ 海量资深编辑老师无缝对接,一对一服务。 ~ 保原创!可加急!免费改!

认证主体张家港市尚博锐艺术培训咨询有限公司
IP属地江苏
统一社会信用代码/组织机构代码
91320582302062995R

1亿VIP精品文档

相关文档