11 2019 档案

摘要:源程序: #include <stdio.h>#define N 5 //快速排序 int pass(int a[],int x,int y){ int temp=a[x]; int i=x+1; int j=y; int stemp; while(1) { while(a[j]>temp) j-- 阅读全文
posted @ 2019-11-28 10:54 bobo哥 阅读(218) 评论(0) 推荐(1) 编辑
摘要:源程序: // // main.cpp // bitree // // Created by duanqibo on 2019/11/25. // Copyright © 2019年 duanqibo. All rights reserved. // #include <iostream> #inc 阅读全文
posted @ 2019-11-25 20:06 bobo哥 阅读(1362) 评论(0) 推荐(0) 编辑
摘要:源程序: // 32 66 90//15,32,9,22,18 43,66,49,35,53 90,78,71,86 //分析:分块查找由索引查找和子表查找两步完成。设n个数据元素的查找表分为m个子表,且每个子表//均为t个元素,则t=n/m 。这样,分块查找的平均查找长度为:// ASL=ASL索 阅读全文
posted @ 2019-11-21 11:04 bobo哥 阅读(404) 评论(0) 推荐(0) 编辑
摘要:源程序: //二分查找法#include <stdio.h>#define MaxSize 8typedef struct{ int stuno; char stuname[20];}TableElem; TableElem stu[]={{1001,"zhang"},{1009,"wang"},{ 阅读全文
posted @ 2019-11-21 10:31 bobo哥 阅读(296) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <stdio.h>#define MaxSize 8typedef struct{ int stuno; char stuname[20];}TableElem; TableElem stu[]={{1001,"zhang"},{1009,"wang"},{2005,"s 阅读全文
posted @ 2019-11-21 09:15 bobo哥 阅读(782) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream> #include <fstream> //包含文件操作的头文件 using namespace std; void main() { ifstream txt1("c:\\TEST.txt"); //建立输入文件对象指针txt1,指向文件"TEST. 阅读全文
posted @ 2019-11-20 20:18 bobo哥 阅读(311) 评论(0) 推荐(0) 编辑
摘要:源程序: #include < iostream > #include < fstream > #include < cmath > #include < vector > #include < iomanip > #include < string > using namespace std; c 阅读全文
posted @ 2019-11-20 20:04 bobo哥 阅读(2408) 评论(0) 推荐(0) 编辑
摘要:源程序: #include < iostream> #include < fstream > using namespace std; void main() { char *p = "C++程序设计" ; ofstream myFile("c:\\C++_9_5_2.txt"); //在工程文件的 阅读全文
posted @ 2019-11-20 19:34 bobo哥 阅读(252) 评论(0) 推荐(0) 编辑
摘要:源程序: #include < iostream > #include < string > #include <iomanip> using namespace std; class Student //定义学生类 { private: string name; //学生姓名 float scor 阅读全文
posted @ 2019-11-20 19:25 bobo哥 阅读(396) 评论(0) 推荐(0) 编辑
摘要:源程序: //直角三角形在派生矩形类,矩形类的参数也由键盘输入。设计这些类并测试他们的功能。 #include < iostream > #include < cmath > using namespace std; class Line//线段基类 { protected: double size 阅读全文
posted @ 2019-11-19 16:21 bobo哥 阅读(449) 评论(0) 推荐(0) 编辑
摘要:源程序: //4.基类是使用极坐标的点类,从它派生一个圆类,圆类用点类的左边作圆心,圆周通过极坐 //标原点,圆类有输出圆心直、圆半径和面积的成员函数。完成类的设计并验证之。 #include < iostream > #include < cmath > using namespace std; 阅读全文
posted @ 2019-11-19 16:13 bobo哥 阅读(652) 评论(0) 推荐(0) 编辑
摘要:矩形类用线段对象的两个坐标作为自己一条边的位置,它具有另外一个边长,能输出矩形的4个点坐标。给出类的定义并用程序验证它们的功能; #include < iostream > #include < cmath > using namespace std; class Point//点类 { prote 阅读全文
posted @ 2019-11-19 15:54 bobo哥 阅读(655) 评论(0) 推荐(0) 编辑
摘要:源程序: //1.设计一个基类,从基类派生圆柱,设计成员函数输出它们的面积和体积; #include < iostream > using namespace std; class Basic//基类 { protected: double r; public: Basic() { r = 0; } 阅读全文
posted @ 2019-11-19 15:17 bobo哥 阅读(2269) 评论(0) 推荐(0) 编辑
摘要:源程序: //4.定义一个 Dog 类,它用静态数据成员 Dogs 记录 Dog 的个体数目,静态成员函数 GetDogs //用来存取 Dogs。设计并测试这个类。 #include < iostream > using namespace std; class Dog { private: st 阅读全文
posted @ 2019-11-19 15:12 bobo哥 阅读(1331) 评论(0) 推荐(0) 编辑
摘要:源程序: //3.编写一个程序,该程序建立一个动态数组,为动态数组的元素赋值,显示动态数组的值并删除动态数组。 #include <iostream> using namespace std; void main() { int i, n, temp = 0; cout << "输入数组大小:"; 阅读全文
posted @ 2019-11-19 15:07 bobo哥 阅读(1487) 评论(0) 推荐(0) 编辑
摘要:源程序: //p114页的程序,一个常量成员函数 #include <iostream> using namespace std; class Base { private: double x, y; const double p; public: Base(double m, double n, 阅读全文
posted @ 2019-11-19 15:03 bobo哥 阅读(210) 评论(0) 推荐(0) 编辑
摘要:源程序: //1.声明复数的类,complex,使用友元函数 add 实现复数加法。 #include < iostream > using namespace std; class Complex { private: double real, image; public: Complex() { 阅读全文
posted @ 2019-11-19 14:54 bobo哥 阅读(3264) 评论(0) 推荐(1) 编辑
摘要:源程序: //2.使用内联函数设计一个类,用来表示直角坐标系中的任意一条直线并输出它的属性。 #include < iostream.h > #include < math.h > class Line { private: int x1, y1, x2, y2; public : //Line() 阅读全文
posted @ 2019-11-19 14:35 bobo哥 阅读(669) 评论(0) 推荐(0) 编辑
摘要:源程序: //1.设计一个点类 Point,再设计一个矩形类,矩形类使用 Point 类的两个坐标点作为矩形的对 //角顶点。并可以输出 4 个坐标值和面积。使用测试程序验证程序。 #include <iostream> using namespace std; class Point //点类 { 阅读全文
posted @ 2019-11-19 14:20 bobo哥 阅读(5506) 评论(1) 推荐(0) 编辑
摘要:源程序: #include < iostream > using namespace std; template <class T> T sum(T a[], int n) { int i; T s = 0; for (i = 0; i< n; i++) s = s + a[i]; return s 阅读全文
posted @ 2019-11-19 14:11 bobo哥 阅读(1247) 评论(0) 推荐(0) 编辑
摘要:源程序: #include < iostream > using namespace std; template <class T> //定义模板 void sort(T a, T b, T c) //T为模板类型 { T array[3], temp; int i, j; array[0] = a 阅读全文
posted @ 2019-11-19 14:05 bobo哥 阅读(1137) 评论(0) 推荐(0) 编辑
摘要:源程序: #include < iostream > #include < string > using namespace std; int strlen(char *str) { int len = 0; while (str[len] != '\0') { len++; } return le 阅读全文
posted @ 2019-11-19 11:35 bobo哥 阅读(684) 评论(0) 推荐(0) 编辑
摘要:源程序: #include < iostream > using namespace std; void print_triangle(char c, int n) { int i, j; for (i = 0; i< n; i++) { for (j = 0; j <= i; j++) { cou 阅读全文
posted @ 2019-11-19 11:23 bobo哥 阅读(1198) 评论(0) 推荐(0) 编辑
摘要:源程序: #include < iostream.h > #include < math.h > double power(double a, int b) { int i; double result = 1.0; for(i=0;i< b;i++) result = result * a; re 阅读全文
posted @ 2019-11-19 11:15 bobo哥 阅读(766) 评论(2) 推荐(0) 编辑
摘要:源程序: #include < iostream > using namespace std; char up(char c) { if (c >= 'a' && c <= 'z') return (c - 32); //大小写字母的ASCII相差32 else return c; } void m 阅读全文
posted @ 2019-11-19 10:56 bobo哥 阅读(787) 评论(0) 推荐(0) 编辑
摘要:源程序: #include < iostream> #include < math.h > using namespace std; void equation_1(int a, int b, int c) { double x1, x2, temp; temp = b*b - 4 * a * c; 阅读全文
posted @ 2019-11-19 10:47 bobo哥 阅读(5009) 评论(0) 推荐(0) 编辑
摘要:源程序: #include < iostream > #include < functional > #include < algorithm > #include < string > using namespace std; void main() { string str1("We are h 阅读全文
posted @ 2019-11-19 10:32 bobo哥 阅读(273) 评论(0) 推荐(0) 编辑
摘要:源程序: 第一种方法: #include <iostream> #include <string> using namespace std; int main() { string str1="i am "; string str2="a teacher."; cout<<"连接前:"<<endl; 阅读全文
posted @ 2019-11-19 10:27 bobo哥 阅读(4296) 评论(0) 推荐(0) 编辑
摘要:声明如下数组: int a[]={1,2,3,4,5,6,7,8}; 先查找4的位置,将数组a复制给数组b,然后将数组a的内容反转,再查找4的位置,最后分别输出数组a和b的内容。 源程序: #include < iostream> #include < algorithm> #include < f 阅读全文
posted @ 2019-11-19 09:59 bobo哥 阅读(243) 评论(0) 推荐(0) 编辑
摘要:源程序: #include < iostream > #include < algorithm > //用于数组排列的头文件 #define N 5 using namespace std; void main() { float *p,sum=0; int i; p = new float[N]; 阅读全文
posted @ 2019-11-19 09:40 bobo哥 阅读(328) 评论(0) 推荐(0) 编辑
摘要:#include <iostream> using namespace std; void main() { int *p,i; p = new int[100]; for (i = 0; i < 100; i++) { *(p + i) = i; //以指针的方式运行 cout << endl; 阅读全文
posted @ 2019-11-19 09:24 bobo哥 阅读(435) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream> using namespace std; void main() { char a='A',b='B'; int ascii_1=53,ascii_2=54;//ASCII 码中的,5 和6 cout<<"字符输出:"<<(int)a<<","<<( 阅读全文
posted @ 2019-11-19 09:14 bobo哥 阅读(620) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <stdio.h> #include <stdlib.h> #define N 80 char s[N]; void fun(long int n) { int i = 0; while (n > 0) { s[i] = n % 10 + '0'; n = n / 10; 阅读全文
posted @ 2019-11-19 09:04 bobo哥 阅读(1976) 评论(0) 推荐(0) 编辑
摘要:源程序: // main.cpp // stack_quhao // Created by duanqibo on 2019/6/29. // Copyright © 2019年 duanqibo. All rights reserved. // 顺序栈的操作,整数进栈,取栈顶元素,栈内剩余元素 # 阅读全文
posted @ 2019-11-12 14:22 bobo哥 阅读(250) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <stdio.h> #include <stdlib.h> //双向链表结点的定义 typedef struct dbnode { int data; struct dbnode *prio, *next; }DbNode, linkdblist; //创建双向链表 Db 阅读全文
posted @ 2019-11-12 13:25 bobo哥 阅读(222) 评论(1) 推荐(0) 编辑
摘要:源程序: #include <stdio.h> #include <stdlib.h> typedef struct node { int data; struct node *next; }linklist; //创建单向循环链表 linklist *creatlist() { linklist 阅读全文
posted @ 2019-11-12 12:53 bobo哥 阅读(290) 评论(0) 推荐(0) 编辑
摘要:源程序: //用一维数组表示顶点,二维数组表示边,已知图的顶点和边,用矩阵表示出顶点和边的值//有效边用户1表示,无效边用0表示#include <stdio.h>#define MaxVerNum 100 typedef struct{ char vexs[MaxVerNum]; //顶点数组,相 阅读全文
posted @ 2019-11-07 11:29 bobo哥 阅读(206) 评论(0) 推荐(0) 编辑
摘要:源程序: #include <iostream>using namespace std; const int n=10; typedef int array[n];void main(){ int start,end; array a={60,34,55,78,90,99,76,85,96,43}; 阅读全文
posted @ 2019-11-06 08:12 bobo哥 阅读(391) 评论(0) 推荐(0) 编辑
摘要:#include <iostream>#define N 5using namespace std; void main(){ double *p; double max,min,temp; p=new double[N]; //分配三个存储单元 for(int i=0;i<N;i++) cin>> 阅读全文
posted @ 2019-11-05 19:15 bobo哥 阅读(159) 评论(0) 推荐(0) 编辑