Skip to main content

[Java] 로또번호생성기

import java.util.*; // Random 클래스를 사용하기 위해.. class ExRandom2 { public static void main(String[] args) { int[] lotto = new int[] {0, 0, 0, 0, 0}; // 로또번호 저장할 배열 int temp, i, j, index=0; // 로또번호정렬, 인덱스에 쓰일 변수 Random rand = new Random(); // 난수생성을 위해 Random클래스 객체생성 while(index<5) { lotto[index++] = rand.nextInt(45)+1; […]

Read More

Bourne 셸 – 다음 조건을 만족하는 셸 스크립트를 작성하라.(2)

문5]. 사용자로부터 숫자를 입력받아서 이를 출력하는 셸 스크립트를 작성하라. 답5]. total=expr $1 + $2 + $3 + $4 + $5 echo ”total = $total” 문6]. Here 자료를 이용하여 문장내 ”kug” 문자열을 검색하는 셸 스크립트를 작성하라. 답6]. grep -i ”kug” << ++ kug       0.1       30       korea kang […]

Read More

Bourne 셸 – 다음 조건을 만족하는 셸 스크립트를 작성하라.(1)

문1]. ”test” 명령을 사용하여 현재 로그인한 사용자가 몇 명인지를 계산하는 셸 프로그램을 작성하라. 답1]. userID=”root” count=0 for n in users do if [ $userID != $n ] then userID=$n count=expr $count + 1 fi done echo ”현재 로그인한 사용자 수 : $count” 문2]. 반복문(while, for, until)을 사용하여 구구단을 표시하는 셸을 작성하라. (그냥 제가 보기 좋게 […]

Read More