C++
Shadow0418
代码改变世界,keep coding ~~
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
今天的小收获
程序功能:继承的应用 代码: #include #include using namespace std; class Student { public: void get_value() { cin>>num>>name>>sex;} void display() { cout<<"num:"<<num<<endl; cout<<"name:"<<na原创 2013-04-26 22:02:22 · 657 阅读 · 0 评论 -
以前看过汉诺塔不过没看懂。。昨天上机问老师勉强看懂了
程序代码: #include using namespace std; void move(char getone,char putone) { cout"<<putone<<endl; } void hanoi(int n,char one,char two,char three) { void move(char getone,char putone); if(n==1) m原创 2013-05-16 21:41:56 · 701 阅读 · 0 评论 -
一个简单地派生程序
问题:设计一个圆类circle和一个桌子类table,另设计一个圆桌类roundtable,它是从前两个类派生出来的,要求输出一个圆桌的高度、面积和颜色等数据。 程序代码: #include using namespace std; class circle { public: circle(double i):x(i) {} void GetArea() {cout<<3.14*x*x<原创 2013-05-17 22:44:24 · 1422 阅读 · 0 评论 -
............
程序: #include using namespace std; int main() { int lower,upper; int v1,v2; cin>>v1>>v2; if(v1==v2) cout<<"v1==v2"<<v1<<endl; if(v1>v2) { upper=v1;lower=v2;} else {upper=v2;lower=v1;} fo原创 2013-05-09 23:07:33 · 610 阅读 · 0 评论 -
标准库string类型
一、string 对象的定义和初始化的方式 1、 string s1; 2、 string s2(s1); 3、 string s3("hello"); 4、 string s4(n,'c'); //将s4初始化为字符'c'的n个副本 二、string 对象的读写 1、读入未知数目的string对象原创 2013-08-15 16:07:40 · 796 阅读 · 0 评论 -
标准库 vector
vector 不是一种数据结构,而是一个类模版,可用来定义任意多种数据类型。 可以用push_back()函数向vector中添加元素,全部添加到vector对象的后面,直接进行赋值不会添加任何元素。 用一个小题目疏通一下:把int型vector复制给int型数组。 #include #include using namespace std; int main() { ve原创 2013-09-13 20:28:37 · 722 阅读 · 0 评论 -
矩阵转置
最近学了线性代数里的矩阵转置,用程序设计贴一下代码如下: #include using namespace std; #define M 2 #define N 3 int main() { int a[M][N],b[N][M]; //a数组存放原始数组,b数组存放转置后的数组 cout<<"输入一个2*3的矩阵"<<endl; for(int i=0;i<M;原创 2013-09-15 22:16:43 · 859 阅读 · 0 评论
分享