自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(114)
  • 收藏
  • 关注

原创 一个简单的类 和 调用

#include using namespace std;class Time{public: //构造函数 Time(); //设置时间函数 void setTime(int, int, int); //24小时制显示时间 void showTime24(); //12小时制显示时间 void showTime12();private: int hour; int

2014-03-21 12:51:32 539

原创 简单的函数模版

#include using namespace std;template T volume(T side1, T side2, T side3){ return side1 * side2 * side3;}int main(){ cout << volume(1, 2, 3) << endl; cout << volume(1.2, 2.0, 3.3) << endl;

2014-03-20 11:32:19 529

原创 function overload 2

#include #include using namespace std;int square(int);double square(double);int main(){ cout << square(8) << endl; cout << square(9.3) << endl; return 0;}int square(int edge){

2014-03-19 23:25:12 794

原创 function overload

#include #include using namespace std;int square(int);double square(double);int main(){ cout << square(8) << endl; cout << square(9.3) << endl; return 0;}int square(int edge){

2014-03-19 23:17:57 708

原创 一个c++小程序

#include int mycube(int);using namespace std;int main(){ int side; cout << "enter the cube side: " << endl; cin >> side; cout << "the volume of the cube is: " << mycube(side) <<

2014-03-18 21:29:17 631

原创 (三)顺序栈main函数

#include "seqstack.h"int main(){ SeqStack stack; initSeqStack(&stack); printf("%d\n", isEmptySeqStack(stack)); PushSeqStack(&stack, 111); PushSeqStack(&stack,

2014-03-18 21:05:46 3112 2

原创 (二)顺序栈函数定义

#include "seqstack.h"int initSeqStack(SeqStack* S){ S->top = 0; return 0;}int clearSeqStack(SeqStack* S){ for (int i=0; itop; i++) S->data[i] = 0; S->top = 0; return 0

2014-03-18 21:04:53 865

原创 (一)顺序栈头文件

#include #include #define STACKMAXSIZE 10typedef struct seqstack{ int data[STACKMAXSIZE]; int top;}SeqStack;int initSeqStack(SeqStack*);int destroySeqStack(SeqStack*);int clearS

2014-03-18 21:03:46 1660

原创 一个斐波那契数列

#include #define FIBONSIZE 20int main(){ int a = 0, b = 1, c, fibon[FIBONSIZE]; for (int i = 0; i < FIBONSIZE; i++){ c = a + b; fibon[i] = c; a = b; b = c; } for (int i = 0; i < FIBONS

2014-03-18 09:31:55 526

原创 (三)链表main函数

#include "linklist.h"int main(){ linklistPtr head; create_linklist(&head); printf("%d\n", head->data); insert_linklist(&head); traversal_linklist(head); del_linklis

2014-03-15 23:44:20 2520

原创 (二)链表头文件

#include #include //define a link node structtypedef struct linklistnode{ int data; struct linklistnode *next;}linklist, *linklistPtr;//declaration create_linklistint create_linklist(l

2014-03-15 23:43:22 933

原创 (一)链表函数定义文件

#include "linklist.h"int create_linklist(linklistPtr* L){ if(!((*L) = (linklistPtr)malloc(sizeof(linklist)))) return 1; (*L)->data = 234; (*L)->next =NULL; return 0; }

2014-03-15 23:41:55 663

原创 (三)线性表菜单

#include "seqlist.h"int main(){ //定义一个线性表变量 SqList sqlist; int choose, position, value; do{ printf("************ seqlist menu ************\n"); printf("\t1 创建顺序表\n"); printf("\t2 判断顺序表是否为空

2014-03-14 17:27:34 969

原创 (二)函数定义文件

#include "seqlist.h"//1 创建一个顺序表int create_SqList(SqListPtr L){ for (int i = 0; i < LISTMAXSIZE; i++) L->data[i] = 0; L->length = 0; return 0;}//2 判断顺序表是否为空int isEmpty_SqList(SqList L){ re

2014-03-14 17:26:50 731

原创 (一)线性表头文件

#include #include #ifndef LISTMAXSIZE#define LISTMAXSIZE 10#endif//定义一个顺序表typedef struct SqList{ int data[LISTMAXSIZE]; int length;}SqList, *SqListPtr;//1 创建一个顺序表int create_SqList(SqList

2014-03-14 17:25:55 7131

原创 二叉树的建立 与 遍历

#include #include //定义一个树节点的结构struct treeNode{ char data; struct treeNode *lchild, *rchlid;};//创建树的各个节点int create_tree(struct treeNode**);//遍历二叉树int show_tree(struct treeNode*);int main(

2014-03-13 15:13:31 639

原创 初始化一棵树

#include #include //定义一个树节点的结构struct treeNode{ char data; struct treeNode *lchild, *rchlid;};//初始化一棵树的根节点int initial_tree(struct treeNode**);int main(){ //定义一个指向树节点的指针,并初始化为空 struct tre

2014-03-13 12:39:02 3598 1

原创 顺序栈的一般操作

#include //define the size of array#define MAXSIZE 100//define new data type: stackstruct stack{ int data[MAXSIZE]; int top;};//defint var seqStacktypedef struct stack seqStack;//crea

2014-03-11 22:28:51 517

原创 线性表操作

/***name: create a seqlistreceive: seqlist addressreturn: int***/int creat(Seqlist* L){ int len; L->length = 0; printf("Enter the length of the seqlist:"); scanf("%d", &len); if (len <= 100)

2014-03-11 16:30:56 574

原创 sort

//sort linklistint sortlink(struct node **L){ struct node * maxPtr; struct node * currentPtr; struct node * prePtr; maxPtr = (*L)->next; currentPtr = (*L)->next; prePtr = (*L)->next; //get

2014-03-10 23:24:52 460

原创 合并两个线性表

/*名称:合并两个线性表功能:从B中查找元素,如果该元素A中没有,则将该元素合并到表A中接收:指向表a的指针,指向表b的指针返回:int*/int union_linerlist(int *a, int *b){ //count用来做脚标,当有值插入到数组中后,count+1,往后挪一位,继续等待插入 //初始化为5,则指向了第一个空位(数组a长度为10,前5位是有值的,后五位为0

2014-03-10 15:36:39 1370

原创 建立一个菜单用来控制链表

/*名称:菜单功能:建立一个菜单用来控制链表接收:void返回:int*/int menulink(void){ struct node *head = NULL; int data = 0, deldata = 0; int choose; printf("************* LINK LIST MENU *************\n"); printf("\t1

2014-03-07 22:08:23 1148

原创 删除链表节点

/*名称:删除链表节点功能:删除一个链表节点接收:链表头节点head, 要删除节点的int型数据返回:int*/int deleteLink(struct node* L, int data){ //delPtr指向要被删除的节点 //prePtr指向要被删除的节点的前一个节点 struct node * delPtr; struct node * prePtr; //让两个

2014-03-07 16:46:05 811

原创 头插法插入链表节点

/*名称:头插法插入链表节点功能:在链表头节点后插入一个链表节点接收:链表头节点head, 插入节点的int型数据返回:int*/int insertLink_head(struct node* L, int data){ //定义一个指向链表节点的指针 struct node *nodePtr; //当链表为空链表时 if ((L->next) == NULL){ //给

2014-03-07 15:09:51 1533

原创 打印链表

/*名称:打印链表功能:打印链表各节点接收:链表头节点head返回:int*/int printLink(struct node* L){ //创建一个结构体指针 struct node * nodePtr; //让这个指针指向头节点的下一个节点 nodePtr = L->next; //当这个节点非空时 while (nodePtr != NULL){ //打印这个节

2014-03-07 12:28:19 994

原创 尾插法插入链表节点

/*名称:尾插法插入链表节点功能:在链表尾部插入一个链表节点接收:链表头节点, 插入节点的int型数据返回:int*/int insertLink_rear(struct node* L, int data){ //rearPtr 用来指向头节点,沿链表行进,最后用来指向最后一个非空节点 struct node * rearPtr; //nodePtr 用来指向新节点 stru

2014-03-07 12:14:50 2031 1

原创 链表学习笔记(一)

从这篇博文学到的,由衷感谢panda点击打开链接/*名称:初始化链表(1)(直接改变主调函数中的指针head)功能:制造一个头节点接收:指向节点的指针地址 &head返回:int*/int ref_initLink(struct node **L){ //L为指向head(指向节点的指针)的指针,用L接收head的地址 //L接收到head的地址(&head)后,用malloc

2014-03-06 11:56:41 624

原创 输入5个城市的空气质量 打印空气质量图

点击(此处)折叠或打开 #includestdio.h> int main(){     //定义循环变量     int i, j, k;     //定义字符串数组,每个元素都是一个字符串,用

2014-03-05 17:09:07 803

原创 打印四个图形

点击(此处)折叠或打开 #include stdio.h> int main(){     int i, j, k;     //---------------第一个图形------------------

2014-03-05 17:09:05 661

原创 从键盘输入一个数,计算从这个数开始 逐一递减的每个数的阶乘

点击(此处)折叠或打开 #include stdio.h> int main(){     //i,j 循环变量,figure用来存储输入的数字,tmp计算每次阶乘时用到 暂时存储阶乘的值,sum计算每个数字阶乘的和时用到

2014-03-05 17:09:02 1590

原创 通过输入 来控制循环 执行计算 和与积

点击(此处)折叠或打开 #include stdio.h> int main(){     int sum1 = 0, sum2 = 1;     //start起始位置,end结束位置,step步长,opt操作,1为求和 2

2014-03-05 17:08:59 654

原创 找出一组整数中最小的整数 程序读取的第一个值 指定了余下值的数目

点击(此处)折叠或打开 #include stdio.h> int main(){     //定义变量,i循环变量,end循环结束标志,接收键盘输入,figure,存储键盘输入的数字,min存储最小值     int i, end, figure, min

2014-03-05 17:08:56 1110

原创 计算几个整数的平均数,通过scanf读取最后一个标志位9999

点击(此处)折叠或打开 #include stdio.h> int main(){     int end = 0, counter = 0;     float sum = 0;     pri

2014-03-05 17:08:54 1247

原创 通过输入第一个值 来决定后续输入的值中 有几个来参与运算

通过输入第一个值 来决定后续输入的值中 有几个来参与运算 格式为 3 100 200 300  结果为600 点击(此处)折叠或打开  #include stdio.h> #include math.h> int main(){

2014-03-05 17:08:52 575

原创 计算1-99之间所有奇数的和

点击(此处)折叠或打开 #include stdio.h> int main(){     int i, sum = 0;     for ( i = 1; i = 99; i++){

2014-03-05 17:08:50 7116

原创 e = 1+ x/1! + x(2)/2! + x(3)/3!......

点击(此处)折叠或打开 #include stdio.h> //计算幂的函数 int mypow(int); //计算阶乘的函数 float factorial(int);

2014-03-05 17:08:47 5152

原创 计算e的值 e = 1+ 1/1! + 1/2! + 1/3!......

点击(此处)折叠或打开 #include stdio.h> //计算阶乘的函数 float factorial(int); //计算e的值 //e = 1+ 1/1! + 1/2! + 1/3!......

2014-03-05 17:08:45 9485

原创 计算阶乘的函数

点击(此处)折叠或打开 #include stdio.h> //计算阶乘的函数 int factorial(int); int main(){     int x;

2014-03-05 17:08:43 2615 1

原创 判断三条边是否能够组成三角形

点击(此处)折叠或打开 #include stdio.h> #include math.h> int main(){     //定义存储三角形三条边的变量     float x, y, z;

2014-03-05 17:08:40 4487

原创 自创的效率较低的排序算法,纯为了练习

从键盘接收一个5位整数,用该算法将其每位上的数字从小到大重新排列要求是:找到最大的元素,与最后一个元素交换,实现从小到大排列。 点击(此处)折叠或打开 #include stdio.h> #include string.h> //数组大小设置为5

2014-03-05 17:08:38 730

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除