![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
MYCODE
文章平均质量分 58
yueyueniao96
这个作者很懒,什么都没留下…
展开
-
查找链表的倒数第K个结点
#include#include struct Node{ int data; Node *next;}node;Node * printt(Node *p1,int n){ Node *pp=p1; Node *q1=pp->next; for(int j=1;j { pp=pp->next; } while(pp->next!=原创 2012-03-16 16:15:07 · 378 阅读 · 0 评论 -
辗转相除法Euclid(欧几里德)
基本算法——辗转相除法问题:输出两个正整数a,b,且0输出其最大公约数p和最小公倍数q解法1——p从a开始,检测p是否能同时整除a和b, 是则停止循环,不是则令p减1,继续检测。q从b开始,检测q是否能同时被a和b整除,是则停止循环,不是则令q增1,继续检测。源程序1#include void main() { int a,b, p, q; do{转载 2012-03-22 20:16:03 · 1738 阅读 · 0 评论 -
西安电子科技大学计算机机试题目 PROBLEM A
#include int val[1001];void bubble_sort(int a[],int n){ int exchange,temp; int i,j; for(i=0;i exchange=0; for(j =0;j if(a[j]>a[j+1]) { temp=a[j+1];a[j+1]=a[j];a[j]=temp原创 2012-03-21 15:24:38 · 2131 阅读 · 0 评论 -
大数的四则运算及求模
//大数的四则运算及求模。数字无位数限制,除法的商支持小数。原文地址::http://patmusing.blog.163.com/blog/static/13583496020114423226253/#include#include#includeusingnamespace std; class BIGINTEGEROPERATIONS{private:转载 2012-03-19 16:39:24 · 565 阅读 · 0 评论 -
十进制整数,计算对应的二进制数包含多少个1,用位操作
32位为例):1.先造表 int[256],保存1-255对应二进制数1的个数。2.对整数a,先求a&255再查表。3.然后(a>>8)&255再查表。4.依次类推,处理完所有位数,将查表所得值相加。 这个最简单的办法是while(a>0){a=a&(a-1);count++;}int fun(int x){ x = (0x555转载 2012-03-19 16:08:49 · 1924 阅读 · 1 评论 -
2010年华中科技大学计算机保研机试题(没做出来...)
题目描述: 不借用任何字符串库函数实现无冗余地接受两个字符串,然后把它们无冗余的连接起来。输入: 每一行包括两个字符串,长度不超过100。输出: 可能有多组测试数据,对于每组数据,不借用任何字符串库函数实现无冗余地接受两个字符串,然后把它们无冗余的连接起来。输出连接后的字符串。样例输入: abc def样例输出: abcdef#i原创 2012-03-19 12:58:46 · 3516 阅读 · 0 评论 -
strcpy,strcat,strlen函数原型
char * str_cpy(char *strDest,const char *strSrc){assert((strDest!=NULL)&&(strSrc !=NULL));char *address=strDest;while( (*strDest++=*strSrc++) != '\0');return address;}char *str_cat(char转载 2012-03-19 17:21:32 · 421 阅读 · 0 评论 -
数组类模板
#include using namespace std;template class Array{ T *list; int size;public: Array(int sz=50);//constructor Array(Array&a);//copy constructor ~Array(); Array&operator=(const Array&原创 2012-03-18 16:28:27 · 470 阅读 · 0 评论 -
顺序栈实现
/* stack.h **顺序栈实现 */ #include using namespace std; #define REALLOCSIZE 10 /*重新分配内存大小*/ template class stack{ public: stack(); ~stack(void){free(_arr);}转载 2012-03-16 23:26:12 · 319 阅读 · 0 评论 -
二叉树递归创建遍历
题目描述:编一个程序,读入用户输入的一串先序遍历字符串,根据此字符串建立一个二叉树(以指针方式存储)。例如如下的先序遍历字符串:ABC##DE#G##F###其中“#”表示的是空格,空格字符代表空树。建立起此二叉树以后,再对二叉树进行中序遍历,输出遍历结果。输入:输入包括1行字符串,长度不超过100。输出:可能有多组测试数据,转载 2012-03-22 23:23:29 · 680 阅读 · 0 评论