Coding_Algorithm/정올 문제풀이
[정올] Language Coder_반복제어문3_자가진단1_code549 (C)
#include int main() { int n, sum=0,cnt=0; scanf("%d", &n); for (int i = 1; sum < n; i += 2) { sum += i; cnt++; } printf("%d %d", cnt, sum); return 0; }
Coding_Algorithm/정올 문제풀이
[정올] Language Coder_반복제어문3_자가진단1_code549 (C)
#include int main() { int n, sum=0,cnt=0; scanf("%d", &n); for (int i = 1; sum < n; i += 2) { sum += i; cnt++; } printf("%d %d", cnt, sum); return 0; }
Coding_Algorithm/정올 문제풀이
[정올] Language Coder_반복제어문2_형성평가A_code139 (C)
#include int main() { int a, b; scanf("%d %d", &a, &b); if (a < b) { for (int i = 1; i
Coding_Algorithm/정올 문제풀이
[정올] Language Coder_반복제어문2_형성평가9_code138 (C)
#include int main() { int a, b; scanf("%d", &a); for (int i = 1; i
Coding_Algorithm/정올 문제풀이
[정올] Language Coder_반복제어문2_형성평가8_code137 (C)
#include int main() { int a, b; scanf("%d %d", &a, &b); for (int i = 1; i
Coding_Algorithm/정올 문제풀이
[정올] Language Coder_반복제어문2_형성평가5_code134 (C)
#include int main() { int n; scanf("%d", &n); for (int i = 1; i
Coding_Algorithm/정올 문제풀이
[정올] Language Coder_반복제어문2_형성평가6_code135 (C)
#include int main() { int a, b, sum=0, n=0; scanf("%d %d", &a, &b); if (a > b) { int tmp = b; b = a; a = tmp; } for (int i = a; i
Coding_Algorithm/정올 문제풀이
[정올] Language Coder_반복제어문2_형성평가5_code134 (C)
#include int main() { int n, even = 0, odd = 0; for (int i = 0; i < 10; i++) { scanf("%d", &n); if (n % 2 == 0) even++; else odd++; } printf("even : %d\n", even); printf("odd : %d", odd); return 0; }
Coding_Algorithm/정올 문제풀이
[정올] Language Coder_반복제어문2_형성평가4_code133 (C)
#include int main() { int n, num, sum=0; double avg; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &num); sum += num; } avg = (double)sum / n; printf("%.2f", avg); return 0; }
Coding_Algorithm/정올 문제풀이
[정올] Language Coder_반복제어문2_자가진단8_code548 (C)
#include int main() { int i, j; for (int i = 2; i < 5; i++) { for (int j = 1; j
Coding_Algorithm/정올 문제풀이
[정올] Language Coder_반복제어문2_자가진단7_code547 (C)
C언어 #include int main() { int i, j; for (int i = 2; i < 7; i++) { for (int j = i; j < i+5; j++) { printf("%d ", j); } printf("\n"); } return 0; } Python for i in range(2, 7): for j in range(0, 5): print("%d "%(i+j), end="") print()
Coding_Algorithm/정올 문제풀이
[정올] Language Coder_반복제어문2_자가진단6_code546 (C)
#include int main() { int n, num, sum=0; double avg; scanf("%d", &n); for (int i = 0; i = 80) printf("pass"); else printf("fail"); return 0; }
Coding_Algorithm/정올 문제풀이
[정올] Language Coder_반복제어문2_자가진단5_code545 (C)
#include int main() { int arr[10], threeCnt=0, fiveCnt=0; for (int i = 0; i < 10; i++) { scanf("%d", &arr[i]); if (arr[i] % 3 == 0) threeCnt++; if (arr[i] % 5 == 0) fiveCnt++; } printf("Multiples of 3 : %d\n", threeCnt); printf("Multiples of 5 : %d", fiveCnt); return 0; } 한가지 봐줘야 할 점은 3의배수, 5의배수를 따로 세고있기때문에 5의배수를 셀 때 else if문이아닌 if문으로 작성해주어야한다는 점입니다. else if문으로 작성시 15같은경우 threeCnt만 카운트되고 fiveCnt..