算法
hangyejiadao
这个作者很懒,什么都没留下…
展开
-
输入一串字符串,中间有空格,然后求出最后的字符串长度
输入:"Hello World Test "输出4代码#include #include using namespace std;int main(){ string s; while(getline(cin,s)){ int n=0,flag=1; for(int i=s.l原创 2016-12-31 17:31:03 · 3860 阅读 · 0 评论 -
冒泡算法
#include#include#includeusing namespace std;#define size 10void BubbleSort(int* arr, int n){ int i, j, temp; for (int i = 0; i < n - 1; i++) { for (int j = 0; j < n - 1 - i; j++) { if原创 2017-01-01 07:57:04 · 225 阅读 · 0 评论 -
快速排序
#include#include#define size 10using namespace std;void Qsort(int a[], int low, int high){ if (low>=high) { return; } int first = low; int last = high; int key = a[first];/*用字表的第一个记录作为枢轴原创 2017-01-01 18:07:55 · 189 阅读 · 0 评论