
C++
文章平均质量分 50
qq_26919527
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
二分查找法--while语句实现
#includeusing namespace std;int main(){ int a[] = {10,20,35,45,52,54,64,68,74,84}; //必须为有序数组 int b; cout << "输入要查找的数字:"; cin >> b; int fist=0, end=9,mid=(fist+end)/2 ; while (a[mid] != b)原创 2015-05-08 21:32:15 · 472 阅读 · 0 评论 -
冒泡排序—while语句实现
//#include#include#includevoid main(){int a[] = { 2, 5, 3, 6, 8, 7, 1, 11, 10 }; int n = sizeof(a) / sizeof(int); //求数组的长度 printf("排序前:"); int i=0; while (i!=n) { printf(" %d",a[i]); /原创 2015-06-14 21:31:22 · 3607 阅读 · 0 评论 -
冒泡排序—for循环实现
//#include#include#includevoid main(){ int a[] = { 2, 5, 3, 6, 8, 7, 1, 11, 10 }; int n = sizeof(a) / sizeof(int); //求数组的长度 printf("排序前:"); for (int i = 0; i < n; i++) //输出排序前的元素 { pri原创 2015-06-14 19:38:10 · 656 阅读 · 0 评论 -
冒泡排序—do-while语句实现
//#include#include#includevoid main(){int a[] = { 2, 5, 3, 6, 8, 7, 1, 11, 10 }; int n = sizeof(a) / sizeof(int); //求数组的长度 printf("排序前:"); int i=0; while (i!=n) { printf(" %d",a[i]);原创 2015-06-14 21:45:44 · 2286 阅读 · 0 评论 -
约瑟夫循环
#includeusing namespace std;//约瑟夫循环typedef struct node{ int data; int password; struct node *next;}Node,*LinkList;LinkList p, t, L;//L为头节点,P为临时节点,t为新节点 int CreatList(int n){ int i;原创 2015-05-19 22:51:50 · 337 阅读 · 0 评论 -
选择排序-for语句实现
#include#include //指定数组, 数组大小void Select(int buf[], int n){ int i, j, temp; int idex; //保存当前最小值下标 标记 for (i = 0; i < n - 1; i++) { idex = i; //当前最小值下标 for (j = i + 1; j < n; j++) {原创 2015-06-23 23:02:43 · 460 阅读 · 0 评论 -
直接插入排序-for语句实现
#include#includevoid Insert(int buf[], int n){ int i, j, temp; for (i = 1; i < n; i++) //从下标为1的元素位置开始比较 { if (buf[i]<buf[i - 1]) //如果i位置的元素小于前一个位置i-1的元素 { temp = buf[i]原创 2015-06-23 22:58:45 · 469 阅读 · 0 评论 -
顺序表操作
#includeusing namespace std;#define size 100typedef struct list{ int data[size]; int length;}list;//创建顺序表void CreateList(list *L, int n){ int i; for (i = 0; i < n; i++) cin >> L->da原创 2015-05-14 23:28:10 · 401 阅读 · 0 评论 -
顺序栈操作
#includeusing namespace std;#define size 100typedef struct stack{ int data[size]; int top;}stack;//初始化顺序栈void CreatStack(stack &s){ s.top = 0;}//判断栈是否为空bool IsEmpty(stack s){ if原创 2015-05-15 20:17:24 · 278 阅读 · 0 评论 -
求一个数的阶乘的结果的位数
#includeusing namespace std;double fac(int);int main(){ int k,n; cin >> n; while ( n--) { int cunt = 1; double t,s; cin >> k; s = fac(k); t = s / 10; while ( t原创 2015-05-01 19:23:39 · 478 阅读 · 0 评论 -
杭州电子科技大学ACM-1081
InputInput consists of several lines of integer numbers. The first line contains an integer n, which is the number of cases to be tested, followed by n lines, one integer 1 ≤ n ≤ 107 on each l原创 2015-05-01 19:41:22 · 484 阅读 · 0 评论 -
求数根
数根是将一正整数的各个位数相加(即横向相加),若加完后的值大于10的话,则继续将各位数进行横向相加直到其值小于10为止,或是,将一数字重复做数字和,直到其值小于10为止,则所得的值为该数的数根#includeusing namespace std;int main(){ int a,r; while (cin >> a && a != 0 &&a>0)原创 2015-05-01 20:17:10 · 666 阅读 · 0 评论 -
单链表的基本操作
#include#include#include#includeusing namespace std;//定义节点结构体typedef struct ListNod { int data; struct ListNod *next;}listnode,*linklist;//初始化链表void Creatlist(linklist *head){ i原创 2015-05-09 18:43:28 · 364 阅读 · 0 评论 -
二分查找法用—for循环— 实现
#includeusing namespace std;int main(){ int a[10] = { 10, 20, 35, 45, 52, 54, 64, 68, 74, 84 }; //必须为有序数组 int fist = 0, end = 9, mid = (fist + end) / 2; int b; cout << "输入目标数:" << endl; cin原创 2015-05-08 23:27:28 · 2202 阅读 · 0 评论 -
求一个数的 a 的 b 次方的结果的最后一位数。
#includeusing namespace std;int main(){ long a, b; int k; while(cin >> a >> b && !(a<0 || b<0)) { int re = a % 10; switch (re) { case 1:cout << 1 << endl; break; case 5:cout <<原创 2015-05-02 23:40:47 · 1629 阅读 · 0 评论 -
二分查找法—do-while实现
#includeusing namespace std;int main(){ int a[10] = {10,20,35,45,52,54,64,68,74,84}; //必须为有序数组 int fist = 0, end = 9, mid = (fist + end) / 2; int b; cout << "输入目标数:" << endl; cin >> b; do原创 2015-05-08 23:00:40 · 455 阅读 · 0 评论 -
通讯簿管理系统
#include#include#include#define MAX_NAME 11#define MAX_SEX 3#define MAX_BIRTHDAY 9#define MAX_TEL 21#define MAX_MOBILE 21#define MAX_FAX 21#define MAX_ADDRESS 101#define MAX_POSTAL_CODE 7转载 2015-09-20 13:14:49 · 358 阅读 · 0 评论