import random
arr = [random.randint(0, 100) for _ in range(100)]
result = 0
for i in range(100):
result += a[i]
result = 0
for i in range(10):
result += a[i * 10]
result += a[i * 10 + 1]
result += a[i * 10 + 2]
result += a[i * 10 + 3]
result += a[i * 10 + 4]
result += a[i * 10 + 5]
result += a[i * 10 + 6]
result += a[i * 10 + 7]
result += a[i * 10 + 8]
result += a[i * 10 + 9]
이 둘 중에 뭐가 더 빠를까요?
위에거는 반복문이라서 조건이랑 분기문이 더 있고, 밑에는 조건이랑 분기가 적은 대신 연산이 더 들어갑니다
파이썬과 C언어 기준 둘 다 다르게 나타날 텐데 둘 다 한번 생각해보세요~~
일단 저도 모릅니다.ㅎ
Author
Anonymous
(125.131)
Comments
3
Anonymous
(125.131)
Anonymous
(125.131)
아 참고로 코드 오류가 있는데 밑에 arr는 a라고 생각하시면 됩니다
Anonymous
(220.88)
Anonymous
(220.88)
전자가 더 빨리 적을 수 있어서 더 빠릅니다.
Anonymous
(211.219)
Anonymous
(211.219)
언롤링 아시는구나~
1
Other posts of
Free Board
Title | Author | Votes | Hits | Created at |
|---|---|---|---|---|
| 0 | 1046 | 11 months ago | ||
| 0 | 935 | 11 months ago | ||
| 0 | 939 | 11 months ago | ||
| 0 | 857 | 11 months ago | ||
| 2 | 794 | 11 months ago |

