C++学习记录
文章平均质量分 53
UnlimitedHorizon
这个作者很懒,什么都没留下…
展开
-
C++第6,7,8章
#include //如用VC++应改为∶#include using namespace std; //如用VC++应取消此行 #include "cylinder.h" #include "point.cpp" #include "circle.cpp" #include "cylinder.cpp" int main() {Cylinder cy1(3.5,6.4,5.2原创 2015-06-15 16:53:11 · 491 阅读 · 0 评论 -
比较3个整数大小、c++
#include using namespace std; int main() { int a,b,c; cin>>a>>b; int max(int a,int b,int c=5); cout return 0; } int max(int a,int b,int c=5) { if(a a=b; if(a a=c; return a; }原创 2015-03-23 23:19:02 · 2483 阅读 · 0 评论 -
引用,比较两数大小。8
#include using namespace std; int max(int &x,int &y) { if(x x=y; return x; } int main() { int a,b; cin>>a>>b; cout return 0; }原创 2015-03-24 17:26:43 · 524 阅读 · 0 评论 -
排序。9
#include using namespace std; float sort(float &x,float &y,float &z) { float t; if(x>y) {t=x; x=y; y=t;} if(x>z) {t=x;x=z;z=t;} if(y>z) {t=y;y=z;z=t;} cout return 0; } int main() { flo原创 2015-03-24 17:51:33 · 437 阅读 · 0 评论 -
为什么程序运行不了?求解
#include #include"string" #include"cstring" using namespace std; class Person { int age; char *name; char gender; public: void display(); Person():age(10),gender('M'){ strcpy(name,"AAA");原创 2015-03-24 22:30:15 · 1250 阅读 · 0 评论 -
第二章
1 #include using namespace std; class Time { public: void set_time(); void show_time(); private: int hour; int minute; int sec;原创 2015-03-28 20:22:27 · 465 阅读 · 0 评论 -
1.12
#include #include using namespace std; int main() { string s[5]; for(int m=0;m cin>>s[m]; for(int i=0;i for(int j=0;j if(s[j]>s[j+1]) { string t; t=s[j]; s[j]=s[j+1]; s[j+1]=t; } for(原创 2015-03-28 20:44:59 · 391 阅读 · 0 评论 -
1.13和1.14
1.13 #include #include using namespace std; int main( ) { longa[5]={10100,-123567, 1198783,-165654, 3456}; intb[5]={1,9,0,23,-45}; floatc[5]={2.4, 7.6, 5.5, 6.6, -2.3 }; voidsort原创 2015-03-28 21:09:37 · 622 阅读 · 0 评论 -
C++第三章
4. #include using namespace std; class Student { public: Student(int n,float s):num(n),score(s){} void display(); private: int num; float score; }; void Student::di原创 2015-04-20 16:10:09 · 864 阅读 · 0 评论 -
C++第四章
1: #include using namespace std; class Complex {public: Complex(){real=0;imag=0;} Complex(double r,double i){real=r;imag=i;} double get_real(); double get_imag(); void display(); pr原创 2015-04-26 20:10:30 · 483 阅读 · 0 评论 -
C++第五章
1: #include using namespace std; class Student {public: void get_value() {cin>>num>>name>>sex;} void display( ) {cout<<"num: "<<num<<endl; cout<<"name: "<<name<<endl; cout<<"sex:原创 2015-05-11 15:43:28 · 597 阅读 · 0 评论 -
Timedata
#include class Time{ public: Time(){} Time(int h,int m,int s) { hour=h; minute=m; second=s; } friend istream & operator>>(istream &,Time &); friend ostream & operator<<(ostream &,Time &);原创 2015-05-18 23:13:35 · 450 阅读 · 0 评论 -
扩展三角形类求面积和打印
//扩展程序:创建一个三角形类 //修改create_object函数,使得程序支持三角形的创建 //和求面积、打印等操作 #include #include using namespace std; #define OK 1 #define ERROR -1 class Shape { public: virtual double getArea() const =0; virtua原创 2015-05-19 20:49:29 · 689 阅读 · 0 评论 -
c++第二章
1#include <iostream>using namespace std;class Time {public:void set_time();void show_time();private: int hour; int minute; int sec; };void Time::set_time() { ci原创 2017-12-25 16:51:49 · 348 阅读 · 0 评论