This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
long total=Runtime.getRuntime().totalMemory();//获取系统内存总数 | |
long free=Runtime.getRuntime().freeMemory();//获取剩余内存 | |
long used=total-free;//获取已使用内存 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Resources res=getResources(); | |
TypedArray icons =res.obtainTypedArray(R.array.icons); | |
Drawable drawable1=icons.getDrawable(0); | |
Drawable drawable2=icons.getDrawable(1); | |
Drawable drawable3=icons.getDrawable(2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int getchar( void ); //读取一个字符, 一般用来去掉无用字符 | |
char *gets( char *str ); //读取一行字符串 | |
#include <stdlib.h> | |
void * malloc( size_t size ); //动态内存分配, 开辟大小为 size 的空间 | |
void qsort( void *buf, size_t num, size_t size, int (*compare)(const void *, const void *) ); //快速排序 | |
Sample: | |
int compare_ints( const void* a, const void* b ) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
using namespace std; | |
bool bin_search(int nums[],int i,int len){ | |
int left=0,right=len-1,middle; | |
while(left<=right){ | |
middle=left+((right-left)>>1); | |
if(i>nums[middle]){ | |
left=middle+1; | |
}else if(i<nums[middle]){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define MAXN 9999 | |
#define DLEN 4 | |
class BigNum { | |
private: | |
int a[1000];//可以控制大数的位数 | |
int len; //大数长度 | |
public: | |
BigNum() {len = 1;memset(a,0,sizeof(a));} | |
BigNum(const int); | |
BigNum(const char*); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ACM大量习题题库 | |
ACM大量习题题库 | |
现在网上有许多题库,大多是可以在线评测,所以叫做Online Judge。除了USACO是为IOI准备外,其余几乎全部是大学的ACM竞赛题库。 | |
USACO | |
http://ace.delos.com/usacogate | |
美国著名在线题库,专门为信息学竞赛选手准备 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Cursor query = this.getContentResolver().query(ContactsContract.Data.CONTENT_URI, new String[] { ContactsContract.Data._ID, ContactsContract.CommonDataKinds.Phone.LABEL, ContactsContract.CommonDataKinds.Phone.NUMBER }, "", null, ""); | |
SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, android.R.layout.simple_list_item_2, query, new String[] { ContactsContract.CommonDataKinds.Phone.LABEL, ContactsContract.CommonDataKinds.Phone.NUMBER }, new int[] { android.R.id.text1, android.R.id.text2 }, 0); | |
mListView.setAdapter(adapter); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Observable; | |
import java.util.Observer; | |
/* | |
* Java 观察者模式示例 | |
*/ | |
class MyDataObservable extends Observable { | |
private String data; | |
public String getData() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#encoding: utf-8 | |
__author__ = 'Dodola' | |
from lxml.html import parse | |
from time import sleep,ctime | |
import time | |
import urllib.request | |
import threading | |
import contextlib | |
import queue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class QuickSort { | |
public static int partition(int[] nums, int p, int r) { | |
int x = nums[r];// 取最后一位作为基准 | |
int i = p - 1; | |
for (int j = p; j < r; j++) { | |
if (nums[j] <= x) { | |
i++; | |
// 交换 |
OlderNewer