Skip to content

Instantly share code, notes, and snippets.

View yao2030's full-sized avatar

yao2030 yao2030

  • Shanghai, China
View GitHub Profile
/*
Licensed under the MIT License
Copyright (c) 2011 Cédric Luthi
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
void to_binary(unsigned long n)
{
int r;
r = n % 2;
if (n >= 2)
to_binary(n / 2);
putchar('0' + r);
}
#pragma mark - NSCoding
- (id)initWithCoder:(NSCoder *)decoder {
self = [super init];
if (!self) {
return self;
}
unsigned int count;
objc_property_t *properties = class_copyPropertyList([self class], &count);
for (NSUInteger i = 0; i < count; i++) {
#include <iostream>
using namespace std;
void Hanoi(int n, char src, char mid, char dest) {
if (n == 1) {
cout << src << " -> " << dest << endl;
return;
}
Hanoi(n-1, src, dest, mid);
cout << src << " -> " << dest << endl;
int BinarySearch(int a[], int size, int p) {
int L = 0;
int R = size - 1;
while (L <= R) {
int mid = (L + R) / 2;
if (p == a[mid]) {
return mid;
} else if (p > a[mid]) {
L = mid + 1;
} else {
#include <iostream>
#include <cmath>
using namespace std;
const int NUMS = 16;
int num[NUMS + 10];
inline int Bit(int n, int i) { return ( n & (1 << i)); }
int main(void) {
#include <iostream>
using namespace std;
struct Problem {
int n;
char src, mid, dest;
};
Problem stack[200];
int main(void) {
cin >> stack[1].n;
#include <iostream>
using namespace std;
int Count(int m, int n) {
if (n == 0 || n == 1) {
return 1;
}
if (n > m) {
return Count(m, m);
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;
const double EPS = 1e-6;
inline double f(double x) { return x * x * x - 5 * x * x + 10 * x - 80; }
int main(void) {
double root, x1 = 0, x2 = 100, y = 0.0;
root = x1 + (x2 - x1) / 2;
extension Int {
func times(block: () -> ()) {
for _ in 0..self {
block()
}
}
func times(block: (Int) -> ()) -> Int {