소주의 수로...
'Travel > 2009 China' 카테고리의 다른 글
겨울의 항주 시호 풍경 (0) | 2010.02.25 |
---|---|
상해 南京路 (0) | 2009.12.31 |
상해 Maglev (0) | 2009.12.31 |
소주의 수로...
겨울의 항주 시호 풍경 (0) | 2010.02.25 |
---|---|
상해 南京路 (0) | 2009.12.31 |
상해 Maglev (0) | 2009.12.31 |
/*
============================================================================
Name : Lotto.c
Author : chobocho
Version :
Copyleft
Description : Lotto
============================================================================
*/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
void lotto(int num, int max_number);
void lotto(int num, int max_number)
{
int number[100] = {0, };
int i = 0;
int prev = 0;
int next = 0;
int temp = 0;
if (num > max_number || max_number < 0 || max_number >= 100)
{
return;
}
for (i = 0; i < max_number; i++)
{
number[i] = i+1;
}
srand((time(NULL)));
for (i = 0; i < 1000; i++)
{
prev = rand() % max_number;
next = rand() % max_number;
temp = number[prev];
number[prev] = number[next];
number[next] = temp;
}
for (i = 0; i < num; i++)
{
printf ("%d ", number[i]);
}
puts("\n");
}
int main(int argc, char **argv) {
lotto(6, 46);
return 0;
}
[CPP] 파일 분할 프로그램 v0.01 (0) | 2010.01.28 |
---|---|
[CPP] 폴더내 파일 목록을 보여 주는 코드 조각 (1) | 2009.03.24 |
함수 포인터 (0) | 2009.01.08 |
[Python] Simple template maker (0) | 2010.02.02 |
---|---|
[Python] 초간단 Lotto 생성기 소스 (0) | 2010.01.22 |
[Python] Simple file viewer (0) | 2010.01.02 |
[Python] 짧은 코드 모음 (0) | 2010.01.22 |
---|---|
[Python] Simple file viewer (0) | 2010.01.02 |
[Python] 회전 이동 (0) | 2009.08.25 |
컴퓨터 추천 도서 (0) | 2010.03.03 |
---|---|
임베디드 프로그래밍 C 코드 최적화 (0) | 2008.08.20 |
스즈미야 하루히 시리즈 (0) | 2008.06.02 |
편지 (0) | 2010.06.01 |
---|---|
가족 (0) | 2010.04.17 |
꽝! 다음 기회를... (0) | 2010.01.31 |
#-*- coding: cp949 -*-
# Name : py_fileview.py
# Author : chobocho.com
# Version :
# Copyright :
# Description : Simple text file viewer
#
from Tkinter import *
import tkMessageBox
import os.path
import glob
class App:
def __init__ (self, master):
frame = Frame(master)
frame.pack()
# Text Area
f0 = Frame(frame, width = 100, height = 100)
f0.grid(row = 0, column = 0)
self.text_scrollbar = Scrollbar (f0, orient=VERTICAL)
self.text = Text(f0, width=80, height = 20, yscrollcommand=self.text_scrollbar.set)
self.text_scrollbar.config(command=self.text.yview)
self.text_scrollbar.pack(side=RIGHT, fill=Y)
self.text.pack()
# List Box area
f1 = Frame(frame, width = 100, height = 100)
f1.grid(row = 0, column = 1)
self.list_button = Button(f1, text="File List", command=self.ShowInfo)
self.list_button.pack()
self.listbox_scrollbar = Scrollbar (f1, orient=VERTICAL)
self.listbox = Listbox(f1, height=19, yscrollcommand=self.listbox_scrollbar.set)
self.listbox_scrollbar.config(command=self.listbox.yview)
self.listbox_scrollbar.pack(side=RIGHT, fill=Y)
# 파일 내용을 읽어서 보여 줄 것
self.ReadTemplate()
self.listbox.bind("<Double-Button-1>", self.LoadFile)
self.listbox.pack(side=RIGHT)
def ClearText(self):
self.text.delete(1.0, END)
def ShowInfo(self):
tkMessageBox.showinfo("Information","http://chobocho.com\nVersion 0.2")
def ReadTemplate(self):
all_flist = glob.glob ("*.txt")
for f in all_flist:
if os.path.exists(f):
self.listbox.insert(END, f.decode('cp949'))
def LoadFile(self, event):
self.items = self.listbox.curselection()
self.el = self.listbox.get(self.items)
self.ClearText()
if os.path.exists(self.el):
self.fp = open(self.el, 'r')
self.tempFileData = self.fp.read()
self.fp.close()
self.text.insert(1.0, self.tempFileData.decode('cp949'))
#----------------------------------------------------------
# main
if __name__ == "__main__":
root = Tk()
app = App(root)
root.mainloop()
[Python] 초간단 Lotto 생성기 소스 (0) | 2010.01.22 |
---|---|
[Python] 회전 이동 (0) | 2009.08.25 |
WxPython - HelloWorld (0) | 2008.12.22 |
소주에서... (0) | 2010.01.24 |
---|---|
상해 Maglev (0) | 2009.12.31 |
항주 대한 민국 임시 정부 (0) | 2009.12.30 |
상해 南京路 (0) | 2009.12.31 |
---|---|
항주 대한 민국 임시 정부 (0) | 2009.12.30 |
중국에서 구매한 기념품 (0) | 2009.12.29 |
고신대 트리축제 구경 2 (0) | 2009.12.25 |
---|---|
고신대 트리축제 구경 1 (0) | 2009.12.25 |