




已阅读5页,还剩7页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
第 6 周: 生成 N 个随机数(1-100) ,排序后输出。要求 1、使用数组实现。2 、使用 vector 实现。 #include using namespace std; int main() const int N=100; vector vec; srand(time(0); for(int i=0;i); print(vec); coutvecj) k=j; int temp=veck;veck=veci;veci=temp; 第 7 周 : 1生成 N 个随机数( 0-99) ,统计落在区间10*i,10*i+9(i:0-9)内的整数个数。 #include #include using namespace std; int main() const int N=10000; int cnt=0; bool isPrime(int); for(int i=0;i!=N;+i) int temp=rand()%10000+1; if(isPrime(temp) +cnt; cout #include #include using namespace std; int main() const int N=10000; static bool aN+1; for(auto al=false; for(int i=2;i using namespace std; int main() const int N=100; vector vec; srand(time(0); for(int i=0;i); print(vec); coutvecj) k=j; int temp=veck;veck=veci;veci=temp; 第 11 周 1. 实现一个 Point 类并测试;(要求 Point 类至少有一个或多个构造函数,一个求两点之 间的距离函数,和一个求该点到原点距离的函数) #include using namespace std; int main() Point p1(1,2); Point p2(3,4); cout #include using namespace std; class Point public: Point(int x,int y) this-x=x; this-y=y; double dist(Point p) return sqrt(x-p.x)*(x-p.x)+(y-p.y)*(y-p.y); private: int x; int y; ; class Triangle public: Triangle(Point p1,Point p2,Point p3) a=p1.dist(p2); b=p1.dist(p3); c=p2.dist(p3); double circumference() return (a+b+c); double area() double p=(a+b+c)/2.0; return sqrt(p*(p-a)*(p-b)*(p-c); private: double a; double b; double c; ; int main() Point p1(1,1); Point p2(1,5); Point p3(4,1); Triangle T(p1,p2,p3); cout using namespace std; class Complex public: Complex()real=0;imag=0; Complex(double r,double i)real=r;imag=i; Complex add(Complex c2); Complex sub(Complex c2); double real; double imag; ; int main() Complex c1; c1.real=1.1;c1.imag=1.2; cout #include #include using namespace std; string haab19=“pop“,“no“,“zip“,“zotz“,“tzec“,“xul“,“yoxkin“,“mol“,“chen“,“yax“,“zac“,“ceh“,“mac“,“k ankin“,“muan“,“pax“,“koyab“,“cumhu“,“uayet“; string tzolkin20=“imix“,“ik“,“akbal“,“kan“,“chicchan“,“cimi“,“manik“,“lamat“,“muluk“,“ok“,“chuen“,“ eb“,“ben“,“ix“,“mem“,“cib“,“caban“,“eznab“,“canac“,“ahau“; int main() int turns; int day,year; string month; char dot; cinturns; cout0) cinday; cindot; cinmonth; cinyear; int i; for(i=0;i using namespace std; int leapYear(int year); int main() cout a b c; int i, result = 0; for(i=1;i using namespace std; class Person public: Person(); person(string newname); void PrintName(); private: string name; person:person(string newname) name=newname; void person:person(string newname) cout using namespace std; class Base public: Base(int i)cout using namespace std; class Complex public: Complex(double r=0.0,double i=0.0) real=r; imag=i; Complex operator+(const Complex Complex operator-(const Complex Complex operator+() return Complex(+real,+imag); Complex operator+(int) return Complex(real+,imag+); Complex operator-() return Complex(-real,-imag); Complex operator-(int) return Complex(real-,imag-); void display()const cout“(“real“,“imag“)“endl; private: double real; double imag; ; int main() Complex c1(5,4),c2(2,10),c3; cout“c1=“;c1.display(); cout“c2=“;c2.display(); c3=c1+c2; cout“c3=c1+c2=“;c3.display(); c3=c1-c2; cout“c3=c1-c2=“;c3.display(); c3=c1;
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025初三升高一数学暑假衔接讲义25讲含答案(必修一内容)3.5.1 二次方程根的分布问题
- 2025年九年级语文中考最后一练口语交际(全国版)(含解析)
- 风景园林基础考研资料试题及参考答案详解【培优b卷】
- 《风景园林招投标与概预算》试题A附参考答案详解(a卷)
- 2025-2026年高校教师资格证之《高等教育法规》通关题库含答案详解(达标题)
- 2025年黑龙江省五常市辅警招聘考试试题题库含答案详解(巩固)
- 2025年STEAM教育在中小学的跨学科融合与创新案例研究
- 胰腺导管内乳头状黏液瘤外科治疗进展2025
- 初三化学最后一课-主题班会【课件】
- 消防设备试题及答案
- 铁尾矿综合利用归纳
- 新生儿败血症护理查房查房
- 北京理工大学答辩模板课件
- 小学思政课《爱国主义教育》
- 胸腔积液与胸腔穿刺教学课件
- 成都医学院辅导员考试真题2022
- 2023届江苏泰州市高港实验校新课标Ⅰ卷中考数学试题(Word精校版)含解析
- PDP个人性格测试题-完整版
- 天津理工大学-PPT 答辩3
- 班组文化建设方案
- 青海省事业单位人员流动审核表
评论
0/150
提交评论