[repl.it] 4.7. For: Number of zeros Solutions/풀이 포스팅 썸네일 이미지

Coding_Algorithm/Python

[repl.it] 4.7. For: Number of zeros Solutions/풀이

몇개를 입력받을지 입력받아 정한 후, 0이라고 입력한 갯수를 세라고 하네요. N = int(input()) cnt=0 for i in range(N): if(int(input()) == 0): cnt += 1; print(cnt) 사실 if문 조건을 저렇게 괄호로 안씌워줘도 됩니다. 근데 C언어를 하던 관성이 남아있어서.. 아 참고로 python3에서는 C언어에서의 ++이 없다는거 알아두세요. (1을 더해주는 기능)

2020.03.17 게시됨

[정올] Language Coder_반복제어문1_형성평가5_code129 (C) 포스팅 썸네일 이미지

Coding_Algorithm/정올 문제풀이

[정올] Language Coder_반복제어문1_형성평가5_code129 (C)

#include int main() { int b=0, h=0; float w=0; char a; while (1) { printf("Base = "); scanf("%d", &b); printf("Height = "); scanf("%d", &h); w = b * h / 2.0f; printf("Triangle width = %.1f\n", w); printf("Continue? "); scanf(" %c", &a); switch (a) { case 'Y': case 'y': break; default: return 0; } } } while True: base = int(input("Base = ")) height = int(input("Height = ")) print("Triangle width ..

2020.03.17 게시됨

[정올] Language Coder_반복제어문1_자가진단5_code540 (C/Python) 포스팅 썸네일 이미지

Coding_Algorithm/정올 문제풀이

[정올] Language Coder_반복제어문1_자가진단5_code540 (C/Python)

뭐, 굉장히 도움되는 힌트네요. #include int main() { int a, sum = 0, num=0; while (1) { scanf("%d", &a); if (a == -1) break; else if (a % 3 == 0) { printf("%d\n", a / 3); } } return 0; } while True: n = int(input()) if n == -1: break elif n % 3 != 0: continue else: print("%d"%(n/3)) 코드를 작성할 때 꼭 -1일때는 먼저 검사해야 할지에 대해 고민해봅시다

2020.03.15 게시됨