自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

ChenYitian

我们还有很多梦没做,还有很多明天要走,要让世界听见我们的歌------信乐团《天高地厚》

  • 博客(91)
  • 收藏
  • 关注

原创 Android UI控件--Spinner

Spinner控件可以让用户从不同的列表项中选出一个,如页码等。一下程序实现了在一个名为spinner的Spinner中,选择一项,在名为SpinnerItem的TextView中进行呈现。public class AtyUsingSpinner extends AppCompatActivity { private Spinner spinner; private Ar

2016-08-02 20:57:02 385

原创 Android中向外部存储读写非字符串类数据

当我们需要读写的数据是整型之类的类型时,使用DataOutputStream会简单一些。代码如下:public class MainActivity extends AppCompatActivity { String str = ""; int[] inint = new int[]{1, 2, 35, 5, 7}; int[] outint = new int[

2016-08-02 11:56:56 287

原创 Android中Context的传递

Android中,Context是一种抽象类,它直接继承了Object,它由Android系统来实现,它可以得到一个应用程序的运行环境。但只能在activity,broadcasting,等中获得,如果要在其他一般类中使用context,需要进行传递。先看看之前写的一段代码:public class MainActivity extends AppCompatActivity { priva

2016-07-30 23:03:24 7870

原创 Android UI控件--单选与复选框

在andriod中,单选通过由RadioButton组成的RadioGroup实现,复选(多选)通过CheckBox 实现。 单选框的XML文件如下:<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:

2016-07-30 22:38:37 2456 1

原创 Android中用intent启动另一个activity

一个程序中很有可能不止

2016-07-30 18:49:50 5678 1

原创 AndroidUI组件 ListView(2)

如果想要在ListView中实现更加复杂的布局(如腾讯新闻客户端那种),就不能使用简单的ArrayAdapter了。应该使用一个Adapter,这个Adapter直接继承自BaseAdapter,这样可以把View作为列表元素。 BaseAdapter是一种抽象类,需要实现它内部的四个抽象方法:getCount方法可以取得列表项的数量getItem通过一个位置取得关联项的数据getItemI

2016-07-28 21:43:47 282

原创 Android UI组件--ListView(1)

ListView是一个公共类,是一种View。它展示了一些垂直排列可以滚动的物件,这些物件通过与这个ListView相关联的ListAdapter决定的。首先现在XML文件中加入一个ListView。 <ListView android:layout_width="fill_parent" android:layout_height="fill_par

2016-07-27 20:19:35 265

原创 noj1202数独游戏

描述数独游戏规则 在9阶方阵中,包含了81个小格(九列九行),其中又再分成九个小正方形(称为宫),每宫有九小格。 游戏刚开始时,盘面上有些小格已经填了数字(称为初盘),游戏者要在空白的小格中填入1到9的数字,使得最后每行、每列、每宫都不出现重复的数字,而且每一个游戏都只有一个唯一的解答(称为终盘)。 输入一个9*9的矩阵,0表示该位置是空白。 输出一个9*9

2016-06-28 18:06:01 393

原创 JAVA中的自定义异常捕获

编写一个程序,将字符串转换成数字。请使用try-catch语句处理转换过程中可能出现的异常。JAVA中提供了自定义异常类,虽说尽量使用定义好的类,但是有时候还是会使用到自定义异常类。自定义异常类格式如下:class /*自定义异常类名*/ extends Exception{ public /*自定义异常类名*/ //相当于重写其构造函数 { super("/*输出的信息*/

2016-05-01 23:30:21 4426 1

原创 广义表的建立与求深度

广义表是一种比较复杂的线性表,它的原子要么是元素,要么是子表,表中除了表头元素以外其他全是表尾,所以表尾一定是子表类型。时限:1000ms 内存限制:10000K  总时限:3000ms描述按表头、表尾的分析方法重写求广义表深度的递归算法 输入输入一串以'('开始,以')'结束的字符串,并且输入的左右括号必须匹配,如:(),(()).. 输出分别输出按表头、

2016-04-30 22:44:02 1106

原创 JAVA中的sort排序

C++中提供了sort函数,可以让程序员轻松地调用排序算法,JAVA中也有相应的函数。1.基本元素排序:Array.sort(排序数组名)package test;import java.util.*;public class main{ public static void main(String args[]) { Scanner cin=new Scanner(Sys

2016-04-30 18:33:15 10579

原创 结构体中运算符的重载

C++中,结构体是无法进行==,>,=,比如二分查找,binary_crearch只能对数组进行查找,如果是结构体数组的话,它会报错。但很可惜,实际编程中,大部分时候操作对象是结构体数组。二分查找结构体数组的程序如下:#include #include #include using namespace std;struct point{ int elem; bool

2016-04-25 15:15:45 48301 3

原创 有关二分查找的STL

时限:1000ms 内存限制:10000K  总时限:3000ms描述给定一个单调递增的整数序列,问某个整数是否在序列中。 输入第一行为一个整数n,表示序列中整数的个数;第二行为n(n不超过10000)个整数;第三行为一个整数m(m不超过50000),表示查询的个数;接下来m行每行一个整数k。 输出每个查询的输出占一行,如果k在序列中,输出Yes,否则输出No。

2016-04-25 12:59:24 423

原创 花生米三连发(动规)

1.时限:1000ms 内存限制:10000K  总时限:3000ms描述五一长假第二天,Tom和Jerry在仓库散步的时候又发现了一堆花生米(这个仓库还真奇怪)。这次Tom制定分花生米规则如下:       1、Tom和Jerry轮流从堆中取出k粒花生米吃掉,k可以是1,5,10中的任意一个数字;        2、为显示规则的公平性,Jerry可以选择先取或者后取。 J

2016-04-23 12:22:24 915 3

原创 字母转换(深搜)

时限:1000ms 内存限制:10000K  总时限:3000ms描述通过栈交换字母顺序。给定两个字符串,要求所有的进栈和出栈序列(i表示进栈,o表示出栈),使得字符串2在求得的进出栈序列的操作下,变成字符串1。输出结果需满足字典序。例如TROT 到 TORT:[i i i i o o o oi o i i o o i o] 输入给定两个字符串,第一个字符串

2016-04-23 12:08:38 446

原创 求图像的周长(深搜)

时限:1000ms 内存限制:10000K  总时限:3000ms描述给一个用 . 和X表示的图形,图形在上、下、左、右、左上、左下、右上、右下8个方向都被看作是连通的,并且图像中间不会出现空洞,求这个图形的边长。输入首先给出m、n、x、y四个正整数,下面给出m×n的图形,x、y表示点击的位置,全0表示结束。 输出点击的图形的周长。 输入样例2 2

2016-04-23 12:06:08 492

原创 旅游预算(复杂深搜)

描述一个旅行社需要估算乘汽车从某城市到另一城市的最小费用,沿路有若干加油站,每个加油站收费不一定相同。旅游预算有如下规则: 若油箱的油过半,不停车加油,除非油箱中的油不可支持到下一站;每次加油时都加满;在一个加油站加油时,司机要花费2元买东西吃;司机不必为其他意外情况而准备额外的油;汽车开出时在起点加满油箱;计算精确到分(1元=100分)。编写程序估计实际行驶在某路线所需的最小费用。 

2016-04-23 12:00:47 1056

原创 找倍数(优先队列解法)

时限:1000ms 内存限制:10000K  总时限:3000ms描述对于每个输入的数字(如:2),则要求 给出一个由1,0构成的十进制整数,且该整数为输入数字的某个倍数,且是满足该条件的最小数(如2对应的10)。 输入数字n,n等于0时停止。 输出n的一个满足条件的最小倍数。 输入样例20 输出样例10 提示 来源

2016-04-23 11:56:47 827

原创 逆波兰表达式的树状解法

描述    一个四则运算算术表达式,只包含“(”,“)”,“+”,“-”,“*”,“/”,括号可嵌套,利用有向无环图的邻接表达式存储,每个操作数原子都由一个小写字母表示。写一个算法输出其逆波兰表达式(又称后缀表达式)。 输入输入长度不超过100的四则运算表达式,中间没有空格,以’#’结尾。 输出输出表达式对应的逆波兰表达式 输入样例(a+b)*c 输

2016-04-10 23:26:41 2403

原创 POJ2387 Til the Cows Come Home(dijkstra求图论最短路)

DescriptionBessie is out in the field and wants to get back to the barn to get as much sleep as possible before Farmer John wakes her for the morning milking. Bessie needs her beauty sleep, so s

2015-05-11 22:55:55 405

原创 POJ1094 Sorting It All Out (不仅仅是拓扑排序)

DescriptionAn ascending sorted sequence of distinct values is one in which some form of a less-than operator is used to order the elements from smallest to largest. For example, the sorted seque

2015-05-09 22:31:05 378

原创 POJ1287 Networking (Kruskal与并查集求解最小生成树)

DescriptionYou are assigned to design network connections between certain points in a wide area. You are given a set of points in the area, and a set of possible routes for the cables that may c

2015-05-09 22:12:03 617

原创 POJ1258 Agri-Net(Prim求解最小生成树)

DescriptionFarmer John has been elected mayor of his town! One of his campaign promises was to bring internet connectivity to all farms in the area. He needs your help, of course.Farmer John

2015-05-09 21:57:12 362

原创 POJ3061 Subsequence (追逐法)

DescriptionA sequence of N positive integers (10 < N < 100 000), each of them less than or equal 10000, and a positive integer S (S < 100 000 000) are given. Write a program to find the minimal

2015-04-26 22:22:13 517

原创 POJ2352 Stars(线段树进阶)

DescriptionAstronomers often examine star maps where stars are represented by points on a plane and each star has Cartesian coordinates. Let the level of a star be an amount of the stars that ar

2015-04-25 20:40:34 363

原创 POJ3264 Balanced Lineup(线段树入门)

DescriptionFor the daily milking, Farmer John's N cows (1 ≤ N ≤ 50,000) always line up in the same order. One day Farmer John decides to organize a game of Ultimate Frisbee with some of the co

2015-04-24 22:18:55 291

原创 POJ3104 Drying (二分的力量2)

DescriptionIt is very hard to wash and especially to dry clothes in winter. But Jane is a very smart girl. She is not afraid of this boring process. Jane has decided to use a radiator to m

2015-04-12 21:52:41 954

原创 POJ2484 A Funny Game (典型博弈论)

DescriptionAlice and Bob decide to play a funny game. At the beginning of the game they pick n(1 6) coins in a circle, as Figure 1 shows. A move consists in removing one or two adjacent coins,

2015-04-12 18:15:45 598

原创 POJ3984 迷宫问题 (BFS与路径记录)

Description定义一个二维数组: int maze[5][5] = { 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0,};它表示一个迷宫,其中的1表示墙壁,0表示可以走的路,只能横着走或竖着走,不能斜着走,要求编程序找出从左上角到右下角的

2015-04-12 18:05:11 457

原创 POJ2785 4 Values whose Sum is 0(二分的力量)

DescriptionThe SUM problem can be formulated as follows: given four lists A, B, C, D of integer values, compute how many quadruplet (a, b, c, d ) ∈ A x B x C x D are such that a + b + c + d = 0

2015-04-10 22:43:14 857

原创 POJ2225 Asteroids! (三维的BFS求最短路)

Asteroids!Time Limit: 1000MS Memory Limit: 65536KTotal Submissions: 3017 Accepted: 1138DescriptionYou're in space. You want to get home. There are asteroids

2015-04-04 23:46:50 441

原创 POJ1458 Common Subsequence (最长公共子序列)

DescriptionA subsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a sequence X = another sequence Z = is a subsequence of X if there exists a st

2015-03-28 22:33:53 425

原创 HDU2046 骨牌铺方格 (一道水题引发的思考)

Problem Description在2×n的一个长方形方格中,用一个1× 2的骨牌铺满方格,输入n ,输出铺放方案的总数.例如n=3时,为2× 3方格,骨牌的铺放方案有三种,如下图: Input输入数据由多行组成,每行包含一个整数n,表示该测试实例的长方形方格的规格是2×n (0 Output对于每个测试实例,请输出铺放方案的总数,每个实

2015-03-22 22:08:02 400

原创 POJ2576 Tug of War (二维的01背包)

DescriptionA tug of war is to be arranged at the local office picnic. For the tug of war, the picnickers must be divided into two teams. Each person must be on one team or the other; the number

2015-03-22 21:47:44 1226 1

原创 CF 523C (字符串处理)

DescriptionA Martian boy is named s — he has got this name quite recently from his parents for his coming of age birthday. Now he enjoys looking for his name everywhere. If he sees that he c

2015-03-22 21:34:06 437

原创 ZOJ 1076 Gene Assembly (贪心求区间不相交问题)

Statement of the Problem With the large amount of genomic DNA sequence data being made available, it is becoming more important to find genes (parts of the genomic DNA which are responsible for

2015-03-22 21:17:42 545

原创 POJ 1088 滑雪 (二维最长上升子序列)

DescriptionMichael喜欢滑雪百这并不奇怪, 因为滑雪的确很刺激。可是为了获得速度,滑的区域必须向下倾斜,而且当你滑到坡底,你不得不再次走上坡或者等待升降机来载你。Michael想知道载一个区域中最长底滑坡。区域由一个二维数组给出。数组的每个数字代表点的高度。下面是一个例子 1 2 3 4 516 17 18 19 615 24 25 20 7

2015-03-20 23:09:48 1437 2

原创 POJ1853 Cat (变形与记录路径的01背包)

DescriptionIn strong winds, sailboats tend to heel leeward (tilt away from the wind) like the one in the picture. Heeling is undesirable for at least two reasons. First, the effective sail area

2015-03-08 22:24:12 1038

原创 POJ2533 Longest Ordered Subsequence (最长上升子序列)

DescriptionA numeric sequence of ai is ordered ifa1 a2 < ... <aN. Let the subsequence of the given numeric sequence (a1,a2, ..., aN) be any sequence (ai1,ai2, ...,aiK), where 1 <=i1

2015-03-07 21:12:24 436

原创 POJ1384 Piggy-Bank (完全背包)

DescriptionBefore ACM can do anything, a budget must be prepared and the necessary financial support obtained. The main income for this action comes from Irreversibly Bound Money (IBM). The idea

2015-03-07 20:58:20 360

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除