08 2017 档案

快速排序法(挖坑+分治)
摘要:#include<iostream>using namespace std; int adjustArray(int s[], int l, int r){ int i = l, j = r, x = s[i]; while (i<j) { while (i < j&&s[j] >= x) j--; 阅读全文

posted @ 2017-08-30 01:15 那年月光 阅读(486) 评论(0) 推荐(0) 编辑

不引用第三方变量交换a和b的值
摘要:方法一:(可操作字符) a = a^b; b = a^b; a = a^b; 方法二:(可操作字符) a=a+b; b=a-b; a=a-b; 方法三:(不可以操作字符) a=a*b; b=a/b; a=a/b; 方法四: swap(a,b); 阅读全文

posted @ 2017-08-29 23:56 那年月光 阅读(1672) 评论(0) 推荐(0) 编辑

判断n是否为质数
摘要:#include #include #include using namespace std; int main() { bool judg = true; int i; while (cin >> i) { if (i < 1) { cout << "请输入1以上的值" << endl; ... 阅读全文

posted @ 2017-08-27 17:51 那年月光 阅读(602) 评论(0) 推荐(0) 编辑

第n个质数
摘要://注:for循环之后第三个式子总会操作一遍。#include using namespace std; int main() { int n; while (cin >> n) { if (n == 1) { cout << 1 << endl; } else if (n == 2) { cout << 3 << endl; } else ... 阅读全文

posted @ 2017-08-19 17:42 那年月光 阅读(447) 评论(0) 推荐(0) 编辑

c 最简单的链表
摘要:#include struct node { int data; struct node *next; //指向本身的指针 }; // main() { struct node a,b,c,*h,*p;//定义结构体和结构体指针 a.data=10; //设置结构体变量的值 b.data=20; c.data=30; h=&a; //设置结构体指针的指向 a.next=... 阅读全文

posted @ 2017-08-03 12:01 那年月光 阅读(184) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示