목록Algorithm (69)
BASIC의 개발 노트
123456789101112131415161718192021222324252627#include int main(void){ int n1 = 0, n2 = 0; char op = 0; scanf("%d%c%d", &n1, &op, &n2); switch(op) { case '+': printf("%d", n1 + n2); break; case '-': printf("%d", n1 - n2); break; case '*': printf("%d", n1 * n2); break; case '/': printf("%.2f", (double)n1 / n2); // type 변환 또는 (1.0 * n1) / n2로 type promotion 가능 break; } return 0;}Colored by Color Sc..
12345678910111213141516171819#include int main(void){ int t1 = 0, t2 = 0, t3 = 0; scanf("%d %d %d", &t1, &t2, &t3); if (t1
1234567891011121314151617181920212223242526272829#include int main(void){ double height = 0.0; double weight = 0.0; double standardWeight = 0.0; // 표준몸무게 double pIndex = 0.0; // 비만도 scanf("%lf %lf", &height, &weight); if (height = 160) standardWeight = (height - 100) * 0.9; else standardWeight = (height - 150) / 2 + 50; pIndex = (weight - standardWeight) * 100 / standardWeight; if (pIndex 20) pr..
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 #include int main(void) { double height = 0.0; double weight = 0.0; double standardWeight = 0.0; // 표준몸무게 double pIndex = 0.0; // 비만도 scanf("%lf %lf", &height, &weight); /* printf에서는 %f와 %lf는 각각 float와 doulbe에 해당하며 이 둘을 따로 구별하지 않고 %f로 통일해서 사용해도 상관없기 때문에 굳이 %lf 출력 형식을 고집할 이유가 없다. 즉 double을 printf로 출력 할 때 %f를 써도 된다. 하지만 ..
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 #include int main() { int i = 0, j = 0; int luckyArr[7] = {0}; int myNumArr[6] = {0}; int isBonus = 0; // 보너스 번호임을 판별하기 위한 변수 int count = 0; // 맞춘 로또 번호 개수 카운트 scanf("%d %d %d %d %d %d %d", &luckyArr[0], &luckyArr[1], &luckyArr[2], &luckyArr[3], &luckyArr[4], &luckyArr[5], &..
1234567891011121314151617181920212223242526#include int main(){ int a, b, c; int tmp = 0; scanf("%d %d %d", &a, &b, &c); if (a > b && a > c){ tmp = a; a = c; c = tmp; }else if (b > a && b > c){ tmp = b; b = c; c = tmp; } if (a + b > c){ printf("yes"); }else{ printf("no"); } return 0;} Colored by Color Scriptercs
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152#include int main(){ int c1, c2; int sum = 0; scanf("%d %d", &c1, &c2); switch(c1){ case 1: sum += 400; break; case 2: sum += 340; break; case 3: sum += 170; break; case 4: sum += 100; break; case 5: sum += 70; break; } switch(c2){ case 1: sum += 400; break; case 2: sum += 340; break; case 3: sum += 17..
1234567891011121314151617181920#include int main(){ int a, b, c, d; int s; scanf("%d %d %d %d", &a, &b, &c, &d); s = a + b + c + d; if (s == 0) printf("모"); if (s == 1) printf("도"); if (s == 2) printf("개"); if (s == 3) printf("걸"); if (s == 4) printf("윷"); return 0;} Colored by Color Scriptercs
1234567891011121314151617#include int main(){ int a, b; scanf("%d %d", &a, &b); if (b % a == 0){ printf("%d*%d=%d\n", a, b / a, b); }else if (a % b == 0){ printf("%d*%d=%d\n", b, a / b, a); }else{ printf("none\n"); } return 0;} Colored by Color Scriptercs
1234567891011121314151617181920212223242526272829303132#include int main(){ double a, b; double maxValue = 0; double powTmp = 1; scanf("%lf %lf", &a, &b); if (a + b > maxValue) maxValue = a + b; if (a - b > maxValue) maxValue = a - b; if (b - a > maxValue) maxValue = b - a; if (a * b > maxValue) maxValue = a * b; if (a / b > maxValue) maxValue = a / b; if (b / a > maxValue) maxValue = b / a; for..