C程序设计第5章外部类型( extern ).ppt

  1. 1、本文档共56页,可阅读全部内容。
  2. 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
* * * * * * * * * #include <iostream.h> void main() { double p,t,sum_e; int i = 1; p = 1; sum_e = 1; do { p=p*i; // 计算i的阶乘 t=1/ p; sum_e=sum_e+t; i = i + 1; //为计算下一项作准备 }while(t>0.00001); cout<<sum_e<<endl; } * #include <iostream.h> #include <math.h> #include<iomanip.h> #include <stdlib.h> void main() { int max, min,x; x=rand()%101+100; //产生一个[100, 200]之间的随机数x cout<<setw(4)<<x; max = x; min =x; // 设定最大数和最小数 for(int i=1;i<10;i++) { x=rand()%101+100; //再产生一个[100, 200]之间的随机数x cout<<setw(4)<<x; if(x > max)max = x; // 若新产生的随机数大于最大数,则进行替换 if(x < min)min = x; // 若新产生的随机数小于最小数,则进行替换 } cout<<endl<<"最大数:"<<max<<",最小数:"<<min<<endl; //输出最大和最小数 } * #include <iostream.h> #include <math.h> #include<iomanip.h> void main() { int x,y,z; for(x=0;x<=100;x++) //可优化为x<=19 for(y=0 ;y<100;y++)// 可优化为y<=33 { z=100-x-y; if(5*x+3*y+z/3.0==100) cout<<setw(5)<<x<<setw(5)<<y<<setw(5)<<z<<endl; } } * * #include <iostream.h> void main() { int score; cout << "请输入成绩"; cin >> score; if (score >= 90) cout << "优 " << endl; else if( (score >= 80) && (score < 90) ) cout << "良 " << endl; else if( (score >= 70) && (score < 80) ) cout << "中 " << endl; else if( (score >= 60) && (score < 70) ) cout << "及格 " << endl; else cout << "不及格 " << endl; } * #include <iostream.h> void main( ) { char ch; cin>>ch; ch=(ch>='A' && ch<='Z')?(ch+32):ch; //判别ch是否大写字母,是则转换 cout<<ch<<endl; } * #include<iostream.h> void main() { int score; int a; cout<<"Input score(0~100):"; cin>>score; a=score/10; switch(a) { case 10: case 9: cout << "优 " << endl; break; case 8: cout << "良 " << endl; break; case 7: cout << "中 " << endl; break; case 6: cout << "及格 " << endl; break; default: cout<<"不及格" << endl; } } * #include <iostream.h> void main( ) { int i=1,sum=0; while (i<=100) { sum=sum+i; i++; } cout<<"sum="<<sum<<endl; } *

文档评论(0)

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

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

1亿VIP精品文档

相关文档