因为痛,所以叫青春

我有一个梦想:穷屌丝变身富屌丝

随笔分类 -  做ACM的那些日子

二叉树查找、删除、遍历、销毁、结点的统计、深度计算、广度优先遍历、非递归先、中、后序遍历
摘要:二叉树结点的查找跟遍历是很容易实现的,但是要想实现二叉树结点的删除,确实是一项很费事的工作下面我只介绍二叉树结点的删除。删除二叉树的结点,会遇到三种情况被删除的结点没有子树。这种情况最容易操作,直接找到该结点,然后让它的父结点指向它的指针为空,然后释放该结点即可被删除的结点只有一个子树。找到该结点,... 阅读全文

posted @ 2014-07-25 09:22 Nice! 阅读(1839) 评论(0) 推荐(0)

POJ 1046Color Me Less
摘要:1 给出散布在三维空间的十六个点 2 然后给出其他的点,求这个点到所给十六个点最近的点 3 #include 4 #include 5 #include 6 using namespace std; 7 int main() 8 { 9 int list[16][3], x, y, z, ... 阅读全文

posted @ 2013-05-24 16:36 Nice! 阅读(377) 评论(0) 推荐(0)

poj 2000Gold Coins
摘要:1 http://poj.org/problem?id=2000 2 这是一道关于数学上数列的问题,题目给出了骑士为国王服务的天数,要求输出骑士得到的金币 3 要想得到最终的答案,最简单的方法就是找到,骑士第几次给国王服役,因为骑士第一次给国王服役一天,然后每次服役都比上一次服役的时间增加一天,这... 阅读全文

posted @ 2013-05-21 11:39 Nice! 阅读(266) 评论(0) 推荐(0)

实验一 线性表的顺序表示与实现
摘要:View Code 实验一 线性表的顺序表示与实现实验目的掌握线性表的顺序存储结构;验证顺序表及其基本操作的实现;掌握数据结构及算法的程序实现的基本方法。实验内容建立含有若干个元素的顺序表;对已经建立的顺序表实现插入、删除、查找、合并等基本操作。#include<stdio.h>#include<stdlib.h>#define OK 1#define TRUE 1#define FLASE 0#define ERROR 0#define INFEASIBLE -1#define OVERFLOW -2#define LIST_INIT_SIZE 100#define 阅读全文

posted @ 2012-09-20 22:06 Nice! 阅读(578) 评论(0) 推荐(0)

HDU1576 A/B
摘要:View Code #includeint x, y;void kzgcd(int a,int b){ if(!b) x = 1, y = 0; else { kzgcd(b,a%b); int t = y; y = x-(a... 阅读全文

posted @ 2012-08-08 16:18 Nice! 阅读(172) 评论(0) 推荐(0)

HDOJ 1071
摘要:View Code Problem Description Ignatius bought a land last week, but he didn't know the area of the land because the land is enclosed by a parabola and... 阅读全文

posted @ 2012-08-07 10:06 Nice! 阅读(348) 评论(0) 推荐(0)

文件查找(c语言 findfirst函数,findnext函数)
摘要:View Code 文件查找_finddata_t的使用 那么到底如何查找文件呢?我们需要一个结构体和几个大家可能不太熟悉的函数。这些函数和结构体在的头文件中,结构体为struct _finddata_t ,函数为_findfirst、_findnext和_fineclose。具体如何使用,... 阅读全文

posted @ 2012-08-06 16:53 Nice! 阅读(9176) 评论(0) 推荐(0)

uva 375 - Inscribed Circles and Isosceles Triangles
摘要:错了好几次,因为在定义pi的时候直接标释成了3.1415926,不能直接标释成这个,要用到反三角函数,注意这点View Code #include#includeconst double pi = acos(-1.0);int main(){ double b, h, r, t, _h, y;... 阅读全文

posted @ 2012-08-03 12:26 Nice! 阅读(417) 评论(0) 推荐(0)

uva
摘要:View Code #include#includeint main(){ double a, b, m, n, s, l, angle; while(scanf("%lf%lf%lf%lf%lf",&a,&b,&s,&m,&n) && a+b+s+m+n) { an... 阅读全文

posted @ 2012-08-03 11:02 Nice! 阅读(105) 评论(0) 推荐(0)

uva10112 Myacm Triangles
摘要:题目已经给出来了公式,求面积的,不过也可以在百度上找到其他的求面积公式,只是想要寻找内部和边缘都没有点的三角形,我刚开始没想到很好的办法,后来看到一位前辈的方法,确实很简单的就能理解了,只是让自己想的话,就算是费上半天的劲,也想不到好的办法View Code #include#includedoub... 阅读全文

posted @ 2012-08-02 20:26 Nice! 阅读(272) 评论(0) 推荐(0)

USACO第三道题
摘要:View Code Friday the ThirteenthIs Friday the 13th really an unusual event? That is, does the 13th of the month land on a Friday less often than on any... 阅读全文

posted @ 2012-08-02 16:17 Nice! 阅读(214) 评论(0) 推荐(0)

uva579 ClockHands
摘要:错的很狗血View Code #include#includeint main(){ double m, n, t; char ch; while(scanf("%lf%c%lf",&m,&ch,&n) && (m||n)) { if(n == 0) ... 阅读全文

posted @ 2012-08-02 11:20 Nice! 阅读(130) 评论(0) 推荐(0)

uva10879 Code Refactoring
摘要:AC如此简单,只要用心做,没什么不可以View Code #includeint main(){ int T, k, f[4], top, j; scanf("%d",&T); for(int i = 0;i < T; i++) { top = 0; ... 阅读全文

posted @ 2012-08-02 10:11 Nice! 阅读(196) 评论(0) 推荐(0)

uvaUVa 10392 - Factoring Large Numbers
摘要:简单,读题加AC用了很短的时间,我自己单独把题目意思揣摩出来的,呵呵View Code #include#includeint main(){ long long f[50000], n, i, k, m; k = 0; for(n = 2;k sqrt(n)) ... 阅读全文

posted @ 2012-08-02 09:47 Nice! 阅读(229) 评论(0) 推荐(0)

USACO第二道题
摘要:View Code Greedy Gift GiversA group of NP (2 ≤ NP ≤ 10) uniquely named friends has decided to exchange gifts of money. Each of these friends might or ... 阅读全文

posted @ 2012-08-02 08:52 Nice! 阅读(220) 评论(0) 推荐(0)

USACO第一道题目
摘要:View Code Your Ride Is HereIt is a well-known fact that behind every good comet is a UFO. These UFOs often come to collect loyal supporters from here ... 阅读全文

posted @ 2012-08-02 08:51 Nice! 阅读(161) 评论(0) 推荐(0)

UVa 550 - Multiplying by Rotation
摘要:这题到底是啥意思啊?》线性同余也不是,好像不是数论里面的内容啊,怎么都看不懂它是在搞什么东西的看了别人的题解,写的代码View Code #includeusing namespace std;int main(){ int k, m, n; while(cin >> k >> m >>... 阅读全文

posted @ 2012-08-01 15:40 Nice! 阅读(172) 评论(0) 推荐(0)

uva350 Pseudo-Random Numbers
摘要:View Code #includeint main(){ int Z, I, M, L, i = 1; while(scanf("%d%d%d%d",&Z,&I,&M,&L) && (Z||I||M||L)) { int f[10002] = {0}, k = -1... 阅读全文

posted @ 2012-08-01 12:27 Nice! 阅读(186) 评论(0) 推荐(0)

uva568 Just the Facts
摘要:View Code #include#includeint main(){ int n, i, j, k; long long s = 0; while(scanf("%d",&n) != EOF) { printf("%5d -> ", n); ... 阅读全文

posted @ 2012-07-31 21:29 Nice! 阅读(167) 评论(0) 推荐(0)

uva408 Uniform Generator
摘要:View Code #include#include#includeint main(){ int m, n, k; while(scanf("%d%d",&m,&n) == 2) { printf("%10d%10d",m,n); if(m < n){... 阅读全文

posted @ 2012-07-31 21:11 Nice! 阅读(222) 评论(0) 推荐(0)