#include
#include
#include
using namespace std;
int num_of_st;
void getdata(vector & v, int n)
{
if (!v.empty())
throw runtime_error("v empty");
int t;
for (int i = 0; i > t...
分类:
编程语言 时间:
2015-04-13 09:43:23
阅读次数:
189
STL智能指针使用方法auto_ptr pi(new int(1024));定义智能指针类(使用计数)实现代码:class RealPtr {
friend class AutoPtr;
int *ip;
size_t use;
RealPtr(int *p) : ip(p), use(1) {}
~RealPtr() { delete ip; }...
分类:
其他好文 时间:
2015-04-13 09:41:23
阅读次数:
194
【数据结构】二叉树层次遍历package 蓝桥练习;public class 二叉树层次遍历 { public static int MAXSIZE = 100; public static Node queue[] = new Node[MAXSIZE]; public static void main(String[] args) {
Node h = new...
分类:
其他好文 时间:
2015-04-13 09:40:58
阅读次数:
134
问题描述:
一数组,含有一堆无序数据,首先将数据按顺序排列,再用二分法实现某个元素的查找,若找到,返回该元素在数组中的下表,否则,返回不存在提示信息。
#include
#include
int *bubble_sort(int a[],int n)//冒泡排序(将数据升序排列)
{
int i;
int j;
int tmp;
for(j=0;j<n-1;++j)//n个元素需要...
分类:
编程语言 时间:
2015-04-13 09:35:57
阅读次数:
149
#include
#include
using namespace std;
typedef struct
{
int coef; //系数项
int exp; //指数项
}ElemType;
typedef struct Node
{
ElemType data;
struct Node *next;
}LNode,*LinkList;
void InitList(Lin...
分类:
其他好文 时间:
2015-04-13 09:35:43
阅读次数:
141
最近写的一个应用涉及到使用GridView显示图片,当使用BaseAdapter传统的的实现时,在真机上快速滚动时会出现OOM情况。
一个临时性的解决方案就是改动图片尺寸,减小内存。这种方法简单却不安全。如果图片够多,也存在依然OOM的情况。
一个有效的方法就是使用异步加载。获取应用程序最大可用内存: int maxMemory = (int) Runtime.getRuntime().maxM...
分类:
移动开发 时间:
2015-04-13 09:33:28
阅读次数:
194
//用结构体数组实现:有三个候选人,每个选民只能选一个人,编写一个选票程序,最终输出候选人的票数(假设有十个选民)
#include
#include
struct Person //声明结构体
{
char name[20];
int count;
}leader[3]={"li",0,"zhang",0,"sun",0}; //定义结构体数组并初值化
int...
分类:
编程语言 时间:
2015-04-13 09:32:53
阅读次数:
217
拓扑排序,不开心持续中
#include
#include
#include
#include
#define maxn 2100
using namespace std;
vector >mapp;
int head[maxn];
int n;
void solve()
{
queueroot;
for(int i=0;i<n;i++)
{
if(!head[i]) root.pus...
分类:
其他好文 时间:
2015-04-13 09:31:28
阅读次数:
114
实现一个通讯录;
通讯录可以用来存储1000个人的信息,每个人的信息包括:
姓名、性别、年龄、电话、住址
提供方法:
1. 添加联系人信息
2. 删除指定联系人信息
3. 查找指定联系人信息
4. 修改指定联系人信息
5. 显示所有联系人信息
6. 清空所有联系人
main.c
#include "contact.h"
//查找联系人,返回下标;
int fi...
分类:
编程语言 时间:
2015-04-13 09:30:43
阅读次数:
166
/* c2-1.h 线性表的动态分配顺序存储结构 */
#define LIST_INIT_SIZE 10
#define LISTINCREMENT 2
typedef struct
{
ElemType *elem;
int length;
int listsize;
}SqList;
/* c2-2.h 线性表的单链表存储结构 */
struct LNode...
分类:
其他好文 时间:
2015-04-13 09:29:48
阅读次数:
153