Skip to content

Instantly share code, notes, and snippets.

View agiletalk's full-sized avatar

chanju Jeon agiletalk

View GitHub Profile
@agiletalk
agiletalk / rand_sample.c
Created March 23, 2011 06:05
rand() 함수 사용 예제
#include <stdio.h>
#include <stdlib.h> // srand(), rand()
#include <time.h> // time()
int main()
{
int random;
// rand 함수로 난수를 만들고 3으로 나눈 나머지로 0, 1, 2만 나오도록 한다.
srand((unsigned)time(NULL));
@agiletalk
agiletalk / DayofYear.cpp
Created March 30, 2011 03:16
오늘 날짜로부터 D-day까지 남은 날짜 구하기
#include <iostream>
using namespace std;
class DayofYear
{
private:
int d_mon;
int d_day;
int t_mon;
@agiletalk
agiletalk / entropy.c
Created April 3, 2011 13:58
정보 엔트로피 구하기 (DIPS Homework #2 2.)
#include <stdio.h>
#include <string.h>
#include <math.h>
#define ASCII 128
// base를 밑으로 하는 x의 로그
double logB(double x, double base)
{
return log(x) / log(base);
@agiletalk
agiletalk / bayer2rgb.c
Created April 3, 2011 21:51
bayer pattern -> rgb (DIPS Homework #2 1.)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define BUFFER 128
// Bayer pattern
char BAYER[2][2] = {
{'G', 'B'},
{'R', 'G'}
@agiletalk
agiletalk / calc.c
Created April 4, 2011 19:14
switch와 함수를 사용하여 무한반복 계산기 작성 (5를 입력시 종료)
#include <stdio.h>
#include <stdlib.h>
// 함수 선언
int addition(int,int);
int subtraction(int,int);
int multiply(int,int);
double divide(int,int);
// main()
@agiletalk
agiletalk / fibonacci.c
Created April 4, 2011 19:28
재귀 함수를 이용한 피보나치 수열
#include <stdio.h>
int fibonacci(int);
int main()
{
int i, n;
printf("n: ");
scanf("%d", &n);
@agiletalk
agiletalk / AndroidFirst.java
Created April 6, 2011 01:53
[예제] 코드로 문자열 출력하기
package org.catchabug.AndroidFirst;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class AndroidFirst extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView MyText = new TextView(this);
@agiletalk
agiletalk / TextViewTest.java
Created April 11, 2011 09:00
[예제] TextView
package org.catchabug.TextViewTest;
import android.app.Activity;
import android.os.Bundle;
public class TextViewTest extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@agiletalk
agiletalk / main.xml
Created April 11, 2011 10:35
[예제] ImageView
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@drawable/pride"
@agiletalk
agiletalk / ButtonEdit.java
Created April 11, 2011 10:54
[예제] Button, EditText
package org.catchabug.ButtonEdit;
import android.app.Activity;
import android.os.Bundle;
import android.view.*;
import android.widget.*;
public class ButtonEdit extends Activity {
/** Called when the activity is first created. */
@Override