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
int pivot_index (int n, int *a) { | |
int i; | |
for (i=1; i<n; i++) { | |
if (a[i] != a[0]) { | |
// pivot exists | |
return a[i] > a[0] ? i : 0; | |
} | |
} | |
// pivot not exists | |
return -1; |
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
void insertion_sort (int n, int *a) { | |
int i, j, swap; | |
for (i=1; i<n; i++) { | |
j = i-1; | |
while (j>=0 && a[j]>a[j+1]) { | |
swap = a[j]; | |
a[j] = a[j+1]; | |
a[j+1] = swap; | |
j--; | |
} |
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
#! /usr/bin/env python | |
# -*- coding:utf-8 -*- | |
num_list = range(10) | |
# use for roop | |
list_sum = 0 | |
for num in num_list : | |
list_sum += num | |
print 'list_sum counted with for roop :', list_sum |
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 sys | |
sys.path.append('../') |
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
#! /usr/bin/env python | |
# -*- coding:utf-8 -*- | |
import sys | |
import numpy as np | |
from math import log |
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
def library_name () : | |
return 'Testlib' |
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
#! /usr/bin/env python | |
# -*- coding:utf-8 -*- | |
import sys | |
sys.path.append('../') | |
from Testlib import * | |
print library_name() |
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.regex.Pattern; | |
import java.util.regex.Matcher; | |
public class CheckHatenaID { | |
public static void main (String[] args) { | |
String hatenaID = "shogonir"; | |
Pattern p = Pattern.compile("[a-zA-Z][a-zA-Z0-9_\\-]{1,30}[a-zA-Z0-9]"); | |
Matcher m = p.matcher(hatenaID); | |
boolean f = m.matches(); |
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
EditText editText = (EditText)findViewById(R.id.edit_text); | |
String editTextString = editText.getText().toString(); | |
TextView textView = (TextView)findViewById(R.id.text_view); | |
textView.setText("EditText string = " + editTextString); |
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
EditText editText = (EditText)findViewById(R.id.edit_text); | |
String editTextString = editText.getText().toString(); | |
TextView textView = (TextView)findViewById(R.id.text_view); | |
textView.setText(getResources().getString(R.string.label, editTextString)); |
OlderNewer