#버블정렬
list = []
temp = ""
input = ""
count = 1
for i in range(5):
a = int(raw_input("Input Number : "))
print "a["+str(i)+"] = "+str(a)
list.append(a)
print "Before sort -> "+str(list)
for i in range(len(list)-1):
for j in range(0, len(list)-1-i):
if(list[j]>list[j+1]):
temp = list[j]
list[j] = list[j+1]
list[j+1] = temp
print "i = "+str(i)+", j = "+str(j)+str(list)
print "After sort -> "+str(list)
-------------------------------------------
#피보나치 수열
# -*- coding: cp949 -*-
one = 1
two = 0
upto = int(raw_input("몇번째 수까지 나열할까요 : "))
for i in range(0, upto):
print int(one)
two += one
print int(two)
one += two
-------------------------------------------
#순차탐색
# -*- coding: cp949 -*-
list = []
for i in range(0, 10):
a = int(raw_input("Input Number : "))
print "a["+str(i)+"] = "+str(a)
list.append(a)
print "Before sort -> "+str(list)
b = int(raw_input("Find Number : "))
for j in range(0, 10):
if(list[j]==int(b)):
print str(j+1)+"번째에 있습니다."
break
추가중...
'Coding > Python' 카테고리의 다른 글
소켓 통신할때 Response 못받아오는 문제 (0) | 2016.01.08 |
---|---|
Selenium 경로설정 (0) | 2016.01.08 |
DB Parser (0) | 2015.12.25 |
파이썬 소켓 프로그래밍 (0) | 2014.08.13 |
Python Blind,Time Based SQL Injection Source (0) | 2014.06.15 |