04 2013 档案

求1+2+…+n, 要求不能使用乘除法、for、while、if、else、switch、case等关键字以及条件判断语句(A?B:C)。
摘要:方法一:利用构造函数和静态数据成员[cpp]view plaincopy#include<iostream>usingnamespacestd;classTemp{public:Temp(){++N;Sum+=N;}staticvoidReset(){N=0;Sum=0;}staticintGetSum(){returnSum;}private:staticintN;staticintSum;};intTemp::N=0;intTemp::Sum=0;intsolution_Sum(intn){Temp::Reset();Temp*a=newTemp[n];delete[]a;a= 阅读全文

posted @ 2013-04-22 19:37 lzm风雨无阻 阅读(3975) 评论(1) 推荐(3) 编辑

二叉排序树
摘要:#include <stdio.h>#include <stdlib.h>typedef struct node{ int data; node *lchild; node *rchild;}TreeNode;void InsertNode(TreeNode *&Node, int n){ if (Node == NULL) { Node = (TreeNode*)malloc(sizeof(TreeNode)); Node->data = n; Node->lchild = Node->rchild = NULL; } else { if ( 阅读全文

posted @ 2013-04-15 21:15 lzm风雨无阻 阅读(159) 评论(0) 推荐(0) 编辑

全排列的递归算法
摘要:#include <stdio.h>void DFS(int arr[], int n, int visited[], int result[], int row){ if (row >= n) { for (int i = 0; i < n; i++) { printf("%d ", result[i]); } printf("\n"); return; } for (int i = 0; i < n; i++) { if (visited[i] == 0) { visited[i] = 1; result[row] = 阅读全文

posted @ 2013-04-15 20:08 lzm风雨无阻 阅读(181) 评论(0) 推荐(0) 编辑

SWUST OJ 赋值了吗
摘要:赋值了吗?Time Limit:1000MSMemory Limit:65535KBSubmissions:170Accepted:48Description现在很多的程序设计语言中,赋值已经是一个不容忽视的问题,如果一个变量在未进行赋值的情况下使用,那么这个值将是不定的(哈哈,我已经被遭了好多次了)!而我写的程序用到的变量实在是太多了,又不想自己统计哪些变量是已经赋值了的,现在就请你帮我统计一下哪些变量已经赋值了。为了简化问题,我们假设最开始仅有变量a中有确定的值。变量为单个小写字母,每行恰好有三个字符,中间一个是赋值运算符'='。请编程求出含N行的程序段运行以后有哪些变量中 阅读全文

posted @ 2013-04-11 16:54 lzm风雨无阻 阅读(840) 评论(0) 推荐(0) 编辑

输出二叉树的所有路径
摘要:#include <stdio.h>#include <stdlib.h>typedef struct node{ char data; node *lchild; node *rchild;}TreeNode;void CreateTree(TreeNode *&Node, char *pstr){ int top = -1; TreeNode *Stack[100]; char ch = *pstr; int j = 0; int t; TreeNode *p = NULL; while(ch != '\0') { switch(ch) { 阅读全文

posted @ 2013-04-09 21:57 lzm风雨无阻 阅读(1520) 评论(0) 推荐(0) 编辑

局域网聊天工具
摘要:个人的一个作品,实现了局域网的聊天,采用MFC多文档多视图编写,主要功能如下:文字聊天,文件传送,QQ表情,魔法表情,屏幕截图,滚动字幕,抖动窗口,运行效果如下:百度网盘下载地址:http://pan.baidu.com/s/1jGjbVim 阅读全文

posted @ 2013-04-08 15:22 lzm风雨无阻 阅读(438) 评论(2) 推荐(0) 编辑

队列求解迷宫最短路径
摘要:#include <stdio.h>typedef struct{ int x; int y; int pre;}Queue;Queue Qu[1000];int Map[20][20];int front, rear;int M, N;int aim[4][2] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};void Print(int front){ int j, k; j = k = front; j = front; while(j != 0) { j = Qu[k].pre; Qu[k].pre = -1... 阅读全文

posted @ 2013-04-06 22:02 lzm风雨无阻 阅读(2791) 评论(0) 推荐(0) 编辑

单链表排序
摘要:单链表排序算法,代码如下:#include <stdio.h>#include <stdlib.h>typedef struct Node{ int data; Node *next;}LinkList;void CreateLinkList(LinkList *pHeader, int nLen, int *arr){ pHeader->next = NULL; LinkList *p; p = pHeader; for (int i = 0; i < nLen; i++) { LinkList *node = (LinkList*)malloc(... 阅读全文

posted @ 2013-04-05 10:24 lzm风雨无阻 阅读(212) 评论(0) 推荐(0) 编辑

< 2025年2月 >
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 1
2 3 4 5 6 7 8

导航

统计

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