While
-
Python WhileComputer Science/Basic Programming with Python 2021. 11. 13. 22:11
While 앞에서 언급된 for loop과 거의 유사한 while loop이다. 코드는 아래와 같다. while condition: code contition 이 True라면, 코드블록을 반복하는 구조이다. 예를들어보자. i = 0 while i 0: pass else print("greater than 0") break는 loop을 끝낼 때 사용한다. i = 0 while True: print(i) if i > 3: break; i += 1 0 1 2 3 4 continue는 현재 실행하는 iteration을 건너뛰고 실행할 수 있다. i = 0 while True: print(i) i += 1 if i > 10: break if i % 2 == 0: i += 1 continue 0 1 3 5 7 9 11
-
Mario | CS50 Week 1Computer Science/CS 50 Harvard 2021. 11. 7. 00:36
Harvard CS50 강의를 한글로 정리한것입니다. 이때까지 학습한 내용으로 블록을 프린트하는 간단한 프로그램을 만들어보자. Question Marks #include int main(void) { printf("????\n"); } 조금더 발전시켜서, for loop을 이용해서 n만큼의 물음표를 프린트하게도 할 수 있다. #include int main(void) { int n = 4; for (int i = 0; i make mario_blocks clang mario_blocks.c -lcs50 -o mario_blocks > ./mario_..