Posts

Showing posts from October, 2018

C언어) C언어를 이용하여 나의 BMI 측정하기(저체중, 표준체중, 과체중) 여러분도 직접 비만도를 측정해보세요~!!

Image
안녕하세요~~ 룰루입니다~!! 오늘은 C언어를 이용하여 BMI를 측정해보는 프로그램을 만들어 보겠습니다~~ 프로그래밍을 하기에 앞서 bmi란, 몸무게를 키(m)의 제곱으로 나눈 값으로 그 값에 따라서 ​ 저체중, 표준체중, 과체중(체중에도 정도가 있더군요 저는 편하게 이 3가지로 분류해 보았습니다.) 으로 분류할 수 있습니다. (실제 20~25는 표준체중, 25이상은 과체중으로 분류합니다.) #include <stdio.h> int  main() {  double  weight, height;  //몸무게와 키를 저장할 변수를 선언합니다.  double  bmi;  //bmi를 저장할 변수를 선언합니다.  printf("몸무게를 입력하세요(kg) : ");   scanf("%lf", &weight);  //몸무게를 weight에 저장합니다.  printf("키를 입력하세요(cm) : ");  scanf("%lf", &height);  //키를 height에 저장합니다.  height = height / 100;  //bmi는 키를 m로 계산하기 때문에 cm로 입력받은 키를 m로 변환합니다.  bmi = weight / (height * height);  //bmi를 계산하는 공식입니다. 몸무게를 키(m)제곱으로 나눠줍니다.  printf("당신의 BMI는 : %.1lf입니다.\n", bmi);  if (bmi >= 20.0 && bmi < 25.0)   printf("표준체중 입니다.\n");  else if (bmi < 20)   printf("저체중 입니다.\n");  else   printf("과체중 ...

python) implementing a simple multiplication table~!!

Hello~~! I'm lulu :-) Today, I'm going to show you how to implement a multiplication table in a real simple way. A = [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 ] B = [ 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 ] for a in B: for b in A: print (a, "*" , b, "=" , a*b) for a in range ( 2 , 10 ): for b in range ( 1 , 10 ): print (a, "*" , b, "=" , a*b) I made multiplication in two ways. First is to use a list and the other one is to use a "range" function. There are many different ways to implement a multiplication table using python or java etc.. In no time, I'll bring some exciting games, and different methods using different languages. If you have any questions or any opinions, tell me you'll be welcomed :-) Thank you :-)

C언어) 잔돈 계산 프로그래밍~!!

Image
안녕하세요~~~ 룰루입니다~!!! 오늘은 C언어 라는 프로그래밍 언어를 사용하여 자판기와 같은 잔돈을 반환하는 프로그램을 만들어 보도록 하겠습니다~~! #include<stdio.h> int main() {  int input, change;  //input은 투입액(내가 내는 돈) , change는 잔돈을 저장할 변수로 설정했습니다~  int w500, w100, w50, w10;  //각 동전의 개수를 저장할 변수를 선언했습니다. (w500은 500원짜리 동전, w100은 100원짜리 동전, w50은 50원 짜리 동전, w10은 10원짜리 동전의 개수라고 생각하시면 됩니다)  printf("투입액을 입력하세요 :");    //이곳은 제가 자판기에 투입하는 금액을 적어주시면 됩니다.  scanf("%d", &input);         //그 금액을 input이라는 변수에 저장합니다. (작은 정수정도의 금액으로 저는 설정할 것이여서 %d를 사용했습니다.)  change = input - 3870;   // 커피값이 저는 3870원이라고 설정을 해놓고(여러가지 동전이 나오게 하기위해^^) 잔돈을 저장할 change라는 변수는 투입액-커피값(3870)이라고 설정했습니다.  w500 = change / 500;  //500원 동전의 개수를 나타냅니다.  change = change % 500;  //잔돈중 500원으로 나눈 후의 잔돈을 의미합니다.  w100 = change / 100;  change = change % 100;  w50 = change / 50;  change = change % 50;  w10 = cha...

C언어) C언어를 이용하여 평균 구하기~!!

Image
안녕하세요~ 룰루입니다~!! 오늘은 C언어를 이용해 평균을 구해보도록 하겠습니다. #include <stdio.h> int  main() {  int  korean, english, math;  //점수 세개를 저장할 국어, 영어, 수학이라는 변수를 선언합니다.  int  total;  // 점수들의 총 합을 저장할 변수를 선언합니다.  double average;  //평균을 따로 선언해 줍니다.  printf("국어, 영어, 수학 점수를 입력하세요 : ");  scanf("%d%d%d", &korean, &english, &math);  //입력받은 점수를 변수에 저장합니다.  total = korean + english + math;  //총 합은 세 과목들의 점수의 합으로 합니다.  average = total / 3.0;  // 평균은 세과목의 합을 3으로 나눈 것 입니다.  printf("총점은 %d이고 평균은 %lf입니다.\n", total, average);  return  0; } ​ ​   여기서 평균은 3으로 안나눠 떨어질 수도 있기 때문에 average를 double, 실수로 선언을 했고 때문에 마지막에 %lf로 출력하셔야 합니다~ (소수점 2자리 정도로 짜르고 싶으시면 %.2lf 이용하시면 됩니다~) 오늘은 간단하게 평균만드는 법을 알아보았습니다~~ 감사합니다~~~ 항상 모든 질문,수정사항, 의견등 환영합니다!! 감사합니다~^^

python) implementing stack using python~!!

Hello~! I'm lulu Today I'm going to implement a stack using python. Using python language to implement a stack, is a facile method. Let's see how can we implement a stack using python. class Stack :     def __init__ ( self ):         self .items = []     def is_empty ( self ):         return not self .items         def push ( self , item ):         self .items.append(item)     def pop ( self ):         return self .items.pop()     def peek ( self ):         if self .items:             return self .items[- 1 ]       In this way, we can implement a stack using python easily :-) If you have any question...

python) 파이썬으로 간단하게 stack 구현하기~!!

안녕하세요~~ 룰루입니다~!! ^_^ 오늘은 간단하게 파이썬으로 stack을 구현하려고 합니다. 파이썬만의 장점으로 stack을 쉽게 구현할 수 있는데요 class Stack :     def __init__ ( self ):         self .items = []     def is_empty ( self ):         return not self .items         def push ( self , item ):         self .items.append(item)     def pop ( self ):         return self .items.pop()     def peek ( self ):         if self .items:             return self .items[- 1 ]       이렇게 하면 간단하게 stack을 구현 할 수 있습니다~!! 항상 모든 질문,수정사항, 의견등 환영합니다!! 감사합니다~^^

JAVA) 자바를 이용한 구구단 게임 1탄~!

Image
안녕하세요~~ 룰루입니다~!! 오늘은 JAVA 프로그래밍 언어를 이용해서 정말 간단하게 구구단게임 하나를 만들어 보도록 하겠습니다~!! (여러 시리즈를 만들어 놓았어요 ㅎㅎ) 오늘은 정말 간단하게 2단~15단 까지중 무작위로 컴퓨터가 문제를 내면 정답일 경우 10점을 획득하고, 오답일 경우 5점을 감점하고 11단이상의 어려운문제를 맞추면 10점을 추가점수로 획득한다는 말을 프린트하는 프로그래밍 코드를 구현해보도록 하겠습니다 ㅎㅎ Math.random()을 쓰시는 공식? 같은것을 알려 드리자면, 정수형으로 type casting(강제형변환)을 했기 때문에 2~15사이의 숫자의 개수 14를 곱하고 시작이 2부터니까 2를 더해주면 해당 범위의 숫자안에서 나오게 할 수 있습니다 ㅎㅎ 1탄이라서 간단하게 만들어 봤습니다 ㅎㅎㅎ 앞으로도 많이 기대해주세요~~ ^^ ​ 항상 모든 질문,수정사항, 의견등 환영합니다!! 감사합니다~^^

JAVA) 시간이 지나도 수정이 필요없는 날짜 코드 알아보기와 성인과 미성년자를 알려주는 프로그램~!

Image
  안녕하세요~ 룰루입니다~!! 오늘은 생년월일을 입력하면 성인인지 미성년자인지를 알려주는 프로그램을 만들어 보도록 하겠습니다!! 오늘은 매우 유용한 코드가 숨어있습니다 ㅎㅎㅎ!!  /*System.currentTimeMillis()    * 1970년 1월 1일 0시 0분 0초부터 지금까지의 시간을 밀리언 초 단위로 표시하는 명령.    * System.currentTimeMillis()/1000/60/60/24/365    *현재 년도를 구하는 식. 밀리언초 /1000 =초  밀리언초/1000/60 = 분     *밀리언초/1000/60/60=시    ,  밀리언초/1000/60/60/24 = 일,  밀리언초/1000/60/60/24/365= 년    */ package input; import java.util.Scanner; public class Test03 {  public static void main(String[] args) {    int cyear = 1970 + (int)(System.currentTimeMillis()/1000/60/60/24/365);  //현재 년도 를 구하는 법      System.out.println(cyear);       //2017년 을 쓰지 않고  System.currentTimeMillis()를 이용해서 현재 년도를 구하면 앞으로 수정하지 않아도 됩니다~!!      Scanner sc = new Scanner(System.in);      System.out.print...

data_structure) implementing binary search tree and searching word algorithm ~!!

Hello~~ I'm lulu! Today, I'm going to show how to implement binary search tree and searching word algorithm using a hundred thousand value which is from Shakespeare's works and lines. Binary search tree is effective when we have to insert, delete, search a lot. I think it is really well balanced because the left side of the tree is smaller than current node, and right side is bigger than current node. Let's see how we can implement this beautiful algorithm using python. import random import pandas as pd class BinarySearchTree :     class Node :         def __init__ ( self , key , value , left , right ):             self .key = key             self .value = [value]             self .left = left         ...