- 浏览: 208120 次
- 性别:
- 来自: 北京
最新评论
-
fuliang:
more cleanner than before
Big Integer Arithmetic -
yaojingguo:
Hi, Liang LiangThanks for the i ...
Redirect and restore stdout in C -
fuliang:
使用gcc编译.cpp,可以使用-lstdc++选项,这样gc ...
Redirect and restore stdout in C
文章列表
struct person {
int no;
int age;
};
struct person verbose() {
struct person yu = { .no = 1, .age = 20 };
struct person xiao = { .age = 20, .no = 8 };
return (struct person) { .no = 2, .age = 30 };
}
struct person succinct() {
struct person yu = { 7, 10};
return (struct ...
#include <stdio.h>
struct node {
int data;
struct node *next;
};
void info(struct node *p) {
if (p == NULL) {
printf("merge result is NULL");
}
while (p != NULL) {
printf("%d ", p->data);
p = p->next;
}
printf("\n");
}
str ...
Ubuntu 10.04 desktop version is used.
1. Install mercurial forest extension.
2. "hg fclone http://hg.openjdk.java.net/jdk7/jdk7" to get the source code.
3. Install openjdk 6. Oracle JDK 6 does not work for me. For details, refer to http://mail.openjdk.java.net/pipermail/build-dev/20 ...
#include <stdio.h>
int count_bit1(int num) {
int count = 0;
while (num > 0) {
num &= (num - 1);
count++;
}
return count;
}
int count_bit2(unsigned int num) {
unsigned int mask1 = 0x55555555;
unsigned int mask2 = 0x33333333;
unsigned int mask4 = 0x0F0F0F0F ...
1 Check the size of all the files or directornies in the current directory.
ls | xargs du -s
A simple one from http://www.ibm.com/developerworks/java/library/j-tiger06164.html.
import java.util.*;
import java.util.concurrent.*;
public class CopyOnWrite {
public static void main(String args[]) {
List list1 = new CopyOnWriteArrayList(Arrays.asList(args));
List list2 = n ...
For subversion, refer to http://nedbatchelder.com/code/utilities/blameall_py.html.
For git, use "git log -S<string> filename".
http://en.wikipedia.org/wiki/ANSI_escape_code
Try:
echo -e "\x1b[1;31mHello world\x1b[0m\x1b[3A"
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
int main(int argc, const char *argv[]) {
int fd;
if ((fd = open("/dev/zero", O_RDONLY)) == -1) {
perror("c ...
GCC manual
wget -r -k -I /onlinedocs/gcc-4.4.5/gcc http://gcc.gnu.org/onlinedocs/gcc-4.4.5/gcc/
binutils documentation
wget -k -r -I /binutils/docs-2.21 http://sourceware.org/binutils/docs-2.21/
#include <stdio.h>
int times5(int n) {
asm ("leal (%1,%1,4), %0"
: "=r" (n)
: "0" (n) );
return n;
}
void test_times5() {
int n = 2;
printf("%d\n", times5(n));
}
#define rep_movsl(src, dest, numwords) \
__asm__ _ ...
http://www.ibm.com/developerworks/linux/library/l-ia.html is a great introduction to inline assembly code in C. But its code examples are not ready to run. So I write the following code to help me understand the article.
#include <stdio.h>
#include <unistd.h>
#define rdtscll(va ...
#include <stdio.h>
typedef char* vay_list;
#define vay_rounded_size(type) \
(((sizeof (type) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
#define vay_start(ap, v) \
((void) (ap = (vay_list) &v + vay_rounded_size (v)))
#define vay_arg(ap, type) \
(ap += vay_rou ...
scanf can be used in very complicated ways.
#include <stdio.h>
void one() {
int a, b;
printf("Input: ");
scanf("%dxx%d", &a, &b);
printf("a = %d, b = %d\n", a, b);
}
void two() {
char array[] = {'a', 'b', '\0'};
printf("arr ...
A great tutorial for learning assembly programming and internals of C and C++.
http://www.drpaulcarter.com/pcasm/