![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C/C++
岳麓丹枫001
这个作者很懒,什么都没留下…
展开
-
windows下msys2安装以及常用软件安装
安装、配置与更新镜像源msys2安装与配置安装常用软件安装 gitpacman -S git安装 vimpacman -S vim安装 ack curl https://beyondgrep.com/ack-v3.5.0 > /bin/ack && chmod 755 /bin/ack安装 python-pip pacman -S python-pip ...原创 2021-03-14 17:12:38 · 1300 阅读 · 0 评论 -
直接插入排序
java版本/************************************************************************* > File Name: DirectInsertSort.java > Author: lxlm > Created Time: 2016年04月27日 星期三 20时21分35秒 ***************原创 2016-04-27 20:42:04 · 296 阅读 · 0 评论 -
链队列的C/C++实现
#include <iostream>using namespace std;const int N = 10;typedef int ELEMTYPE;typedef struct Node{ ELEMTYPE data; struct Node * next;}LNode;typedef struct queue{ LNode *head; LNode原创 2016-05-11 23:29:04 · 513 阅读 · 0 评论 -
单链表C/C++实现
#include <iostream>using namespace std;const int N = 10;typedef int ELEMTYPE;typedef struct Node{ ELEMTYPE data; Node *next;}LNode,*LinkList;void initLinkList(LinkList &L);int ins原创 2016-05-11 23:54:56 · 321 阅读 · 0 评论 -
顺序队列C/C++实现
#include <iostream>using namespace std;const int MAXSIZE = 1000;typedef int ELEMTYPE;const int N = 10;typedef struct { ELEMTYPE data[MAXSIZE]; int head; int tail;}Queue;Queue Q;void i原创 2016-05-12 18:13:14 · 559 阅读 · 0 评论 -
直接插入排序
#include <iostream>using namespace std;const int N = 10;int data[] ={6,1,2,7,9,3,4,5,10,8};void directInsertSort(int* data,int n);void printArray(int* data, int n);int main(){ directInsertSort(原创 2016-05-12 19:40:55 · 301 阅读 · 0 评论 -
折半插入排序
#include <iostream>using namespace std;const int N = 10;int data[] = {6,1,2,7,9,3,4,5,10,8};void binaryInsertSort(int* data,int n);void printArray(int* data, int n);int locate(int*data,int i);int m原创 2016-05-12 19:56:18 · 345 阅读 · 0 评论 -
快速排序2
#include <iostream>using namespace std;const int N = 10;int data[]= {6,1,2,7,9,3,4,5,10,8};void quickSort(int* data, int low,int high);void printArray(int* data, int n);int partition(int* data,int原创 2016-05-12 20:26:16 · 356 阅读 · 0 评论 -
求二叉树的宽度C语言版
#include #include #define M 100typedef struct BTNode{ char data; struct BTNode *lchild; struct BTNode *rchild;}BTNode;typedef struct Queue{ BTNode *data[M]; int f; int r;}Queue;void原创 2016-06-22 20:17:14 · 6135 阅读 · 0 评论 -
各种排序算法集锦
#include <stdio.h>#include <malloc.h>void swap2(int a, int b);void swap(int* data, int m, int n);void printArray(int* data, int n);void bubble1(int* data, int n);//冒泡排序1void bubble2(int* data, int原创 2016-05-24 15:39:54 · 347 阅读 · 0 评论 -
线性表的链式存储C语言版
#include #include #define N 10typedef struct Node{ int data; struct Node *next;}Node, *LinkedList;void initList(LinkedList *L);int ListInsert(LinkedList *L, int index, int e);int ListDe原创 2016-06-22 19:00:09 · 411 阅读 · 0 评论 -
线性表的顺序存储结构C语言版
#include #define MAXSIZE 101#define N 10typedef struct SeqList{ int data[MAXSIZE]; int length;}SeqList;void initList(SeqList *L);int Listinsert(SeqList *L, int index, int e);int Listdele原创 2016-06-22 19:04:11 · 597 阅读 · 0 评论 -
二叉树的建立与递归遍历C语言版
#include #include typedef struct BTNode{char data;struct BTNode *lchild;struct BTNode *rchild;}BTNode;void createTree(BTNode* *T){char ch = getchar();if(ch=='#') {*T=原创 2016-06-22 19:36:31 · 1308 阅读 · 0 评论 -
求两个数的最大公约数
方法一int mgcd(int a, int b){ int t; if(a<b) { a = a+b; b = a-b; a = a-b; } while(b) { t = b; b = a%b; a = t; } return a;}方法二int mgcd2(int a,int b){ if(b==0) retur原创 2016-07-09 19:11:25 · 315 阅读 · 0 评论 -
两个数互换
方法一 void swap(int &a, int &b){ a = a + b; b = a - b; a = a - b;}方法二 void swap(int &a, int &b) { a ^= b; b ^= a; a ^= b; }方法三 void swap(int &a, in原创 2016-09-16 21:20:59 · 352 阅读 · 0 评论 -
两个栈实现一个队列
方法:定义两个栈分别为 A,B;入队void enQueue(ELEMTYPE e){ A.push(e);}出队ELEMTYPE deQueue(ELEMTYPE e){ if(B.isEmpty()) { while(A.isEmpty()==false) { B.push(A.pop()); } } retu原创 2016-09-16 21:43:42 · 279 阅读 · 0 评论 -
添加native service
Native Service转载 2016-08-25 18:21:42 · 424 阅读 · 0 评论 -
选择排序
Java版本/************************************************************************* > File Name: ChooseSort.java > Author: lxm > Created Time: 2016年04月27日 星期三 19时54分22秒 **********************原创 2016-04-27 20:10:00 · 226 阅读 · 0 评论 -
改进冒泡排序
Java版本/************************************************************************* > File Name: BubbleSort.java > Author: lxm > Created Time: 2016年04月27日 星期三 19时24分50秒 **********************原创 2016-04-27 19:35:43 · 400 阅读 · 0 评论 -
选择排序
代码:#include int data[] = {3,1,2,4,7,6,8};void printData(int data[],int length);void chooseSort(int data[], int length);void swap(int *a, int *b);#define N 7int main(void){ printData(data,N);原创 2016-04-13 16:55:39 · 271 阅读 · 0 评论 -
判断两个数是否互质
Problem Description 输入两个整数,判断他们是否互质。Input 两个整数。(多组数据)Output 如果他们互质,则输出“yes”,否则,输出“no”。Sample Input2 3Sample Outputyes#include using namespace原创 2014-12-04 13:42:50 · 7886 阅读 · 0 评论 -
求最简分数
Problem Description 这天老师给小豪出了一道很简单题目放松:输入一个分数,让你求出它们的最简分数。Input 第一行包括一个T,表示测试数据的组数。接下来T行每行包括一个分数。(分子分母均在int范围内)Output 对于每个测试样例,输出一行其最简分数。Sample Input32/63/111/36原创 2014-12-04 13:43:23 · 1217 阅读 · 0 评论 -
A+B
Problem Description Calculate A + B.InputEach line will contain two integers A and B. Process to end of file.OutputFor each case, output A + B in one line.Sample Input1 1原创 2014-12-04 13:35:26 · 433 阅读 · 0 评论 -
统计字母数字等个数
Problem Description 输入一串字符,统计这串字符里的字母个数,数字个数,空格字数以及其他字符(最多不超过100个字符)Input多组测试数据,每行一组Output每组输出一行,分别是字母个数,数字个数,空格字数以及其他字符个数Sample InputI am a student in class 1.I think I c原创 2014-12-04 13:39:22 · 824 阅读 · 0 评论 -
求和
Problem Description 求Sn=2+22+222+…+22…222(有n个2)的值。 例如:2+22+222+2222+22222(n=5),n由键盘输入。InputnOutput和Sample Input5Sample Output24690#include using原创 2014-12-04 13:40:23 · 462 阅读 · 0 评论 -
手机短号
Problem Description 大家都知道,手机号是一个11位长的数字串,同时,作为学生,还可以申请加入校园网,如果加入成功,你将另外拥有一个短号。假设所有的短号都是是 6+手机号的后5位,比如号码为13512345678的手机,对应的短号就是645678。现在,如果给你一个11位长的手机号码,你能找出对应的短号吗?Input输入数据的第一行是一个N(N原创 2014-12-04 13:41:09 · 1063 阅读 · 0 评论 -
开灯问题
Problem Description 计算中心有8个机房,每个机房有n台电脑。每台电脑都有一个编号,比如8号机房编号就为H1到Hn,我们有时又称为H1为1号机器,H2为2号机器,...。 有一天我们学校跻身世界高校100强,全校所有师生都进行了狂欢庆祝。罗老师是个很爽快的人,也很喜欢喝酒,那天他喝多了点。但不巧的是那天晚上正好罗老师值班,罗老师是个很负责的老师。所以他就把8号机房打开原创 2014-12-04 13:44:37 · 850 阅读 · 0 评论 -
C++_直接插入排序
#include using namespace std;void insertSort(int a[], int n){ for(int i=1;i { if(a[i] { int temp = a[i]; int j; for(j=i-1原创 2014-12-28 12:15:58 · 343 阅读 · 0 评论 -
日期问题
Problem Description 输入一个用年月日表示的日期,求该日期是该年的第几天。输入某年的第几天,输出这一天是该年的几月几号,茂茂解不出,需要你的帮助。Input开始有个整数k,表示询问的种类,如果k=1,后面有三个合法的整数a,b,c,表示输入的年月日,此时输出该日期是该年的第几天;如果k=2,后面有两个合法的整数a,b,求a年的第b天的日期。保证所有的输入合法。Ou原创 2014-12-04 13:46:10 · 511 阅读 · 0 评论 -
C++折半插入排序
代码如下:#include <iostream>using namespace std;void insertSort(int a[], int n){ for(int i=1;i<n;++i) { if(a[i]<a[i-1]) { int low = 0; int high = i-1;原创 2015-10-30 14:01:24 · 1418 阅读 · 0 评论 -
弓形矩阵
Problem Description输出n*m的弓型矩阵 Input多组测试数据 每组输入2个整数 n和m(不大于20) Output输出n*m的弓型矩阵,要求左上角元素是1,(每个元素占2个位置,靠右) Sample Input4 3 Sample Output1 2 3 6 5 4 7 8 9 12 11 10源代码#include <iostream>#i原创 2015-10-30 14:12:29 · 2767 阅读 · 0 评论 -
工作日志
编译android原创 2016-03-02 12:49:51 · 399 阅读 · 0 评论 -
选择排序
#include <stdio.h>#define N 7void chooseSort(int a[], int n);void swap(int a[], int m, int n);int main(void){ int a[] = {1,4,8,3,5,7,2}; int i; chooseSort(a,N); for(i=0;i<N;i++)原创 2016-03-10 19:53:51 · 321 阅读 · 0 评论 -
直接插入排序
#include <stdio.h>#define N 7void insertSort(int a[], int n);int a[] = {1,5,7,3,2,8,6};int main(void){ int i; insertSort(a,N); for(i=0;i<N;++i) { printf("a[%d]=%d\n",i,a[i]原创 2016-03-10 20:23:23 · 279 阅读 · 0 评论 -
闰年判断
Problem Description 输入年份,判断是否闰年Input输入一个整数n(多组数据)Output如果是闰年,输出yes,否则输出no(每组数据一行)Sample Input2000Sample Outputyes#include using namespace std;int原创 2014-12-04 13:37:52 · 475 阅读 · 0 评论