随笔分类 -  c++

1 2 3 4 5 ··· 15 下一页
收集本人教学中的一些程序
摘要:源程序: #include <stdio.h>#include <iostream>#include <stdlib.h>using namespace std;int main(){ char* p; char a[80]; p = a; int i = 0; while((*p=getchar( 阅读全文
posted @ 2023-10-20 15:20 bobo哥 阅读(29) 评论(0) 推荐(0) 编辑
摘要:#include <iostream>using namespace std; class myComplex{private: double real,imag;public: myComplex(); myComplex(double r,double i); void outCom(); my 阅读全文
posted @ 2022-11-19 20:37 bobo哥 阅读(39) 评论(0) 推荐(0) 编辑
摘要:#include <iostream>#include <cmath>using namespace std; class Point{private: double x,y; friend class Line;public: Point(double i=0,double j=0) { x=i; 阅读全文
posted @ 2022-11-19 19:17 bobo哥 阅读(30) 评论(0) 推荐(0) 编辑
摘要:#include <iostream>using namespace std; class myComplex //复数类{private: double real,imag;public: myComplex(); myComplex(double r,double i); friend clas 阅读全文
posted @ 2022-11-19 18:48 bobo哥 阅读(36) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>using namespace std;class constClass{private: const int conMbr; int Mbr;public: constClass():conMbr(0),Mbr(100){}; constClass( 阅读全文
posted @ 2022-11-12 20:43 bobo哥 阅读(34) 评论(0) 推荐(0) 编辑
摘要:源程序: //编写一个程序,将从键盘输入的n个字符串保存在一个一维数组A中。在输入字符串之前,先输入n的值。//要求,数组A需要动态申请空间,程序运行结束前再释放掉。//再输出n字符串中最长和最短的串,计算平均字符中的长度。#include <iostream>#include <string>us 阅读全文
posted @ 2022-07-03 16:56 bobo哥 阅读(161) 评论(0) 推荐(0) 编辑
摘要:程序一: #include <iostream>#include <stdlib.h>#define COST 20using namespace std;class tiji //体积{private: double length, width, height; //长宽高public: tiji 阅读全文
posted @ 2022-06-26 17:07 bobo哥 阅读(49) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>using namespace std;class A{public: virtual void printMe() { cout<<"This is class A printing."<<endl; }} ;class B:public A{pub 阅读全文
posted @ 2022-04-10 10:50 bobo哥 阅读(39) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>using namespace std; class B;class A{private: int i;public: int set(B&); int get() { return i; } A(int x) { i = x; }}; class B 阅读全文
posted @ 2022-04-10 10:28 bobo哥 阅读(43) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>using namespace std; class birth{private: int year,month,day;public: birth(int x,int y,int z) { year=x; month=y; day=z; } void 阅读全文
posted @ 2022-03-27 11:36 bobo哥 阅读(42) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>using namespace std; void sort(int L[],int n){ int j,k,flag,temp; flag=n-1; while(flag>0) { k=flag-1; flag=0; for(j=0;j<=k;j++ 阅读全文
posted @ 2022-03-27 11:18 bobo哥 阅读(69) 评论(0) 推荐(0) 编辑
摘要:声明复数类Complex,该类中有两个私有变量real , image分别表示一个复数的实部和虚部。 为Complex类添加适当的构造函数,并使用友元函数 add实现复数加法。 #include <iostream>using namespace std; class Complex{private 阅读全文
posted @ 2022-03-20 15:12 bobo哥 阅读(96) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>using namespace std; class Based{public: Based() { cout<<"Based构造函数\n"; fun(); } virtual void fun() { cout<<"Base::fun()函数\n"; 阅读全文
posted @ 2022-03-20 14:58 bobo哥 阅读(56) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>using namespace std; class example{private: int a;public: example(int b=5) { a=b++; } void print() { a=a+1; cout<<a<<" "; } vo 阅读全文
posted @ 2022-03-20 14:49 bobo哥 阅读(65) 评论(0) 推荐(0) 编辑
摘要:源程序: 要求输出结果为40 #include <iostream>using namespace std; class Test{ static int x; //程序填空public: Test(int i=0) { x=i+x; } int Getnum() { return Test::x+ 阅读全文
posted @ 2022-03-20 11:47 bobo哥 阅读(50) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>using namespace std; class line;class box{private: int color; int upx,upy; int lowx,lowy;public: friend int same_color(line l, 阅读全文
posted @ 2022-03-20 11:40 bobo哥 阅读(40) 评论(0) 推荐(0) 编辑
摘要:源程序: 下列程序,输出结果为150。 #include <iostream>using namespace std; class Arr{ int *a,n;public: Arr():a(0),n(0){} Arr(int *aa,int nn) { n=nn; a=new int [n]; f 阅读全文
posted @ 2022-03-20 11:16 bobo哥 阅读(45) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>using namespace std; int main(){ int max(int a,int b,int c=0); int a,b,c,m1,m2; cin>>a>>b>>c; m1=max(a,b,c); //程序填空 m2=max(a,b 阅读全文
posted @ 2022-03-07 20:11 bobo哥 阅读(35) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>using namespace std; class toy{private: int num,price;public: toy(int q,int p) { num=q; price=p; } int get_num() { return num; 阅读全文
posted @ 2022-03-06 11:53 bobo哥 阅读(34) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>using namespace std;int time=0,end=0;class Test{public: Test() { if(time==0) //程序填空 cout<<"欢迎使用测试程序!"<<endl; time=time+1; } ~T 阅读全文
posted @ 2022-03-06 11:45 bobo哥 阅读(26) 评论(0) 推荐(0) 编辑

1 2 3 4 5 ··· 15 下一页