This file contains hidden or 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
| int sum_elements(int[] array, int numOfElements) | |
| { | |
| int sum = 0; | |
| int index = 0; | |
| while(index < numOfElements) | |
| sum += array[index++]; | |
| return sum; | |
| } |
This file contains hidden or 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
| // n번째 피보나치 수열 반환 | |
| // n = 0, 1, 2, ... | |
| int fibonacci(int nth) | |
| { | |
| int n1 = 0; | |
| int n2 = 1; | |
| int n3; | |
| // F_0 = 0 , F_1 = 1 | |
| if(nth == 0 || nth == 1) |
This file contains hidden or 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
| int i; | |
| for(i=1; i<=10; i++); | |
| { | |
| std::cout << i << " "; | |
| } |
This file contains hidden or 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.sql.Timestamp; | |
| import java.text.SimpleDateFormat; | |
| import java.util.Date; | |
| import java.util.Locale; | |
| public class TimeUtil { | |
| public static Timestamp getTimestamp(){ | |
| Timestamp timestamp = new Timestamp(System.currentTimeMillis()); | |
| return timestamp; | |
| } |
This file contains hidden or 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
| // ERROR! | |
| void printArray(int arr[][]) | |
| { | |
| for(int i=0; i<2; i++) | |
| for(int j=0; j<3; j++) | |
| cout << a[i][j] << " "; | |
| cout << endl; | |
| } |
This file contains hidden or 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 MainActivity extends android.support.v4.app.FragmentActivity { | |
| // Only one MapView instance is allowed per MapActivity, | |
| // so we inflate it in the MainActivity and tie its | |
| // lifetime here to the MainActivity. Package scope | |
| // so we can grab them from different instances of map | |
| // fragments. | |
| // | |
| // The other option was to make them static, but that causes | |
| // memory leaks on screen rotation. | |
| View mMapViewContainer; |
This file contains hidden or 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
| #!/usr/bin/env python | |
| import itertools | |
| class Graph(dict): | |
| def __init__(self, vs=[], es=[]): | |
| """create a new graph. (vs) is a list of vertices; | |
| (es) is a list of edges.""" | |
| for v in vs: | |
| self.add_vertex(v) | |
This file contains hidden or 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 urllib | |
| import BeautifulSoup | |
| data = urllib.urlopen('http://www.fdic.gov/bank/individual/failed/banklist.html') | |
| soup = BeautifulSoup.BeautifulSoup(data) | |
| banklist = soup.find('table', attrs={'class', 'sortable'}) |
This file contains hidden or 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
| @Override | |
| public void onTextChanged(CharSequence s, int start, int before, int count){ | |
| if(start >0 && before == 1 && count == 1){ | |
| if(geocoderTask != null){ | |
| gecoderTask.cancel(true); | |
| } | |
| geocodeTask = new GeocodeTask(); | |
| } | |
| } |
This file contains hidden or 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 random | |
| import numpy as np | |
| def gen_sim_pure_python(): | |
| """Pure Python""" | |
| prices = [[np.random.randint(5,1000)] for i in range(10)] | |
| changes = [[np.random.uniform(-0.3, 0.3) for i in range(90)] for i in range(10)] | |
| for p, c in zip(prices, changes): | |
| for delta in c: | |
| p.append(p[-1]*(1+delta)) |
OlderNewer