-
Notifications
You must be signed in to change notification settings - Fork 51
전다빈 report8 제출! #65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
samjan29
wants to merge
9
commits into
beatitudo331:main
Choose a base branch
from
samjan29:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
전다빈 report8 제출! #65
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d342b26
전다빈 Report1, 2 제출합니다
samjan29 88fa745
전다빈 Report1, 2 제출합니다
samjan29 d030d7b
Merge remote-tracking branch 'origin/main'
samjan29 b5643ae
add: report3,4
samjan29 e5c4e4f
modify: report1_3
samjan29 db3d476
add: report5
samjan29 49aa3ca
add: report6
samjan29 fd90bac
add: report7
samjan29 7e0c5eb
add: report8
samjan29 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| 2-4번 문제 | ||
|
|
||
| 정답 : byte b = 256; => overflow 발생 | ||
| char c = ''; => char 타입은 빈 문자 불가능 | ||
| char answer = 'no'; => char 타입은 문자 하나만 가능 | ||
| float f = 3.14 => float 타입이기 때문에 리터럴에 접미사 f 붙여야 하고, 끝에 세미콜론 붙여야 함 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| 2-7번 번 문제 | ||
|
|
||
| 정답 : System.out.println("1" + "2"); => 3 | ||
| System.out.println(true+""); => true | ||
| System.out.println('A' + 'B'); => 65 + 66 = 131 | ||
| System.out.println('1' + 2); => 49 + 2 = 51 | ||
| System.out.println('1' + '2'); => 49 + 50 = 99 | ||
| System.out.println('J' +"ava"); => Java | ||
| System.out.println(true + null); => 오류 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| package jeondabeen.report1; | ||
| // 2-8 번 문제 <- 이렇게 문제 번호 작성 필수 | ||
| public class Report1_3 { | ||
| public static void main(String[] args) { | ||
| int x = 1; | ||
| int y = 2; | ||
| int z = 3; | ||
|
|
||
| int tmp = x; | ||
| x = y; | ||
| y = z; | ||
| z = tmp; | ||
|
|
||
| //예상 결과 : x=2, y=3, z=1 | ||
| System.out.println("x="+x); | ||
| System.out.println("y="+y); | ||
| System.out.println("z="+z); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| 3-1번 문제 | ||
|
|
||
| 정답 : b = (byte)i; | ||
| float f = (float)l; => 실수형이 정수형보다 더 크기 때문 | ||
| i = (int)ch; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| package jeondabeen.report2; | ||
| // 3-2번 문제 | ||
| public class Report2_2 { | ||
| public static void main(String[] args) { | ||
| int x = 2; | ||
| int y = 5; | ||
| char c = 'A'; // 'A'의 문자코드는 65 | ||
|
|
||
| System.out.println(y >= 5 || x < 0 && x > 2); // true || false && false -> true || false -> true => ||보다 &&가 우선순위 높음 | ||
| System.out.println(y += 10 - x++); // y += 10 - 2 -> y = y + 8 -> y = 13 -> (x = 3) | ||
| System.out.println(x += 2); // x = x + 2 -> x = 5 | ||
| System.out.println(!('A' <= c && c <= 'Z')); // !(true && true) -> !true -> false | ||
| System.out.println('C' - c); // 67 - 65 = 2 | ||
| System.out.println('5' - '0'); // 5 | ||
| System.out.println(c + 1); // 65 + 1 = 66 | ||
| System.out.println(++c); // B => 증감연산자 반환 타입은 피연산자랑 같음 | ||
| System.out.println(c++); // B => 후위형 증감연산, 메서드 호출 후 증가 | ||
| System.out.println(c); // C | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package jeondabeen.report2; | ||
|
|
||
| public class Report2_3 { | ||
| public static void main(String[] args){ | ||
| int num = 456; | ||
| System.out.println(num / 100 * 100); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package jeondabeen.report2; | ||
|
|
||
| public class Report2_4 { | ||
| public static void main(String[] args){ | ||
| int numOfApples = 123; // 사과의 개수 | ||
| int sizeOfBucket = 10; // 바구니의 크기(바구니에 담을 수 있는 사과의 개수) | ||
| int numOfBucket = numOfApples % sizeOfBucket > 0 ? numOfApples / sizeOfBucket + 1 : numOfApples / sizeOfBucket; // 모든 사과를 담는데 필요한 바구니의 수 | ||
|
|
||
| System.out.println("필요한 바구니의 수 :"+numOfBucket); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package jeondabeen.report2; | ||
|
|
||
| public class Report2_5 { | ||
| public static void main(String[] args) { | ||
| int num = 10; | ||
| System.out.println(num > 0 ? "양수" : (num < 0 ? "음수" : "0")); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| package jeondabeen.report2; | ||
|
|
||
| public class Report2_6 { | ||
| public static void main(String[] args){ | ||
| int fahrenheit = 100; | ||
| float celcius = 5F / 9 * (fahrenheit - 32); | ||
| int tmp = (int) (celcius * 1000); | ||
| float result = tmp % 10 >= 5 ? (tmp - (tmp % 10) + 10) / 1000F : tmp - (tmp % 10) / 1000F; | ||
|
|
||
| System.out.println("Fahrenheit:" + fahrenheit); | ||
| System.out.println("Celcius:" + result); | ||
| //예상 결과 : Fahrenheit:100, Celcius:37.78 | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| //4-1. 다음의 문장들을 조건식으로 표현해보세요. | ||
|
|
||
| //int형 변수 x가 10보다 크고 20보다 작을 때 true인 조건식 | ||
| if (x > 10 && x < 20) | ||
|
|
||
| //char형 변수 ch가 공백이나 탭이 아닐 때 true인 조건식 | ||
| if (ch != '\n' && ch != '\t') | ||
|
|
||
| //char형 변수 ch가 'x' 또는 'X'일 때 true인 조건식 | ||
| if (ch == 'x' || ch == 'X') | ||
|
|
||
| //char형 변수 ch가 숫자('0'~'9')일 때 true인 조건식 | ||
| if (ch >= '0' && ch <= '9') | ||
|
|
||
| //char형 변수 ch가 영문자(대문자 또는 소문자)일 때 true인 조건식 | ||
| if ((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z')) | ||
|
|
||
| //int형 변수 year가 400으로 나눠떨어지거나 또는 4로 나눠떨어지고 100으로 나눠떨어지지 않을때 true인 조건식 | ||
| if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)) | ||
|
|
||
| //boolean형 변수 powerOn이 false일 때 true인 조건식 | ||
| if (!powerOn) | ||
|
|
||
| //문자열 참조변수 str이 "yes"일 때 true인 조건식 | ||
| if (str.equals("yes")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| package jeondabeen.report3; | ||
|
|
||
| public class Report3_10 { | ||
| public static void main(String[] args) { | ||
| // 1~100사이의 임의의 값을 얻어서 answer에 저장한다. | ||
| int answer = (int) (Math.random() * 100) + 1; | ||
| int input = 0; //사용자입력을 저장할 공간 | ||
| int count = 0; //시도횟수를 세기위한 변수 | ||
|
|
||
| // 화면으로 부터 사용자입력을 받기 위해서 Scanner클래스 사용 | ||
| java.util.Scanner s = new java.util.Scanner(System.in); | ||
| do { | ||
| count++; | ||
| System.out.print("1과 100사이의 값을 입력하세요 : "); | ||
| input = s.nextInt(); //입력받은 값을 변수 input에 저장한다. | ||
|
|
||
| if (input < answer) { | ||
| System.out.println("더 큰 수를 입력하세요."); | ||
| } else if (input > answer) { | ||
| System.out.println("더 작은 수를 입력하세요."); | ||
| } else { | ||
| System.out.println("맞혔습니다."); | ||
| System.out.println("시도횟수는 " + count + "번입니다."); | ||
| break; | ||
| } | ||
| } while(true); //무한반복문 | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| package jeondabeen.report3; | ||
|
|
||
| public class Report3_2 { | ||
| public static void main(String[] args) { | ||
| int sum = 0; | ||
|
|
||
| for (int i = 1; i <= 20; i++) { | ||
| if (i % 2 == 0 || i % 3 == 0) continue; | ||
| sum += i; | ||
| } | ||
| System.out.println("sum=" + sum); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| package jeondabeen.report3; | ||
|
|
||
| public class Report3_3 { | ||
| public static void main(String[] args) { | ||
| int sum = 0; | ||
| int totalSum = 0; | ||
|
|
||
| for (int i = 1; i <= 10; i++) { | ||
| sum += i; | ||
| totalSum += sum; | ||
| } | ||
|
|
||
| System.out.println("totalSum="+totalSum); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| package jeondabeen.report3; | ||
|
|
||
| public class Report3_4 { | ||
| public static void main(String[] args) { | ||
| int sum = 0; // 총합을 저장할 변수 | ||
| int s = 1; // 값의 부호를 바꿔주는데 사용할 변수 | ||
| int num = 0; | ||
|
|
||
| while (sum < 100) { | ||
| if (num != 0 && num % 2 == 0) { | ||
| s = 1; | ||
| } else if (num % 2 != 0) { | ||
| s = -1; | ||
| } | ||
|
|
||
| num = (Math.abs(num) + 1) * s; | ||
| sum += num; | ||
| } | ||
| System.out.println(); | ||
| System.out.println("num="+num); | ||
| System.out.println("sum="+sum); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package jeondabeen.report3; | ||
|
|
||
| public class Report3_5 { | ||
| public static void main(String[] args) { | ||
| int k = 0; | ||
| while (k <= 10) { | ||
| System.out.print("*".repeat(k + 1)); | ||
| System.out.println(); | ||
| k++; | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| package jeondabeen.report3; | ||
|
|
||
| public class Report3_6 { | ||
| public static void main(String[] args) { | ||
| for (int i = 1; i <= 6; i++) { | ||
| for (int j = 1; j < 6; j++) { | ||
| if (i + j == 6) { | ||
| System.out.println("[" + i + ", " + j + "]"); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| package jeondabeen.report3; | ||
|
|
||
| public class Report3_7 { | ||
| public static void main(String[] args) { | ||
| String str = "12345"; | ||
| int sum = 0; | ||
|
|
||
| for (int i = 0; i < str.length(); i++) { | ||
| sum += str.charAt(i) - '0'; | ||
| } | ||
|
|
||
| //예상 결과 : sum=15 | ||
| System.out.println("sum=" + sum); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package jeondabeen.report3; | ||
|
|
||
| public class Report3_8 { | ||
| public static void main(String[] args){ | ||
| int value = (int) (Math.random() * 6) + 1; | ||
| System.out.println("value:"+value); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| package jeondabeen.report3; | ||
|
|
||
| import java.util.Arrays; | ||
|
|
||
| public class Report3_9 { | ||
| public static void main(String[] args) { | ||
| int num = 12345; | ||
| int sum = 0; | ||
|
|
||
| while (num > 0) { | ||
| sum += num % 10; | ||
| num /= 10; | ||
| } | ||
|
|
||
| System.out.println("sum="+sum); | ||
| } | ||
| } |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| int[] arr[]; | ||
| => int[] arr; OR int arr[]; | ||
|
|
||
| int[] arr[] = new int[3][]; | ||
| => int[][] arr = new int[3][]; OR int arr[][] = new int[3][]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| int[][]arr ={ | ||
| {5,5,5,5,5}, | ||
| {10,10,10}, | ||
| {20,20,20,20}, | ||
| {30,30} | ||
| }; | ||
|
|
||
| arr[3].length => 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| package jeondabeen.report4; | ||
|
|
||
| public class Report4_3 { | ||
| public static void main(String[] args){ | ||
| int[] arr = {10, 20, 30, 40, 50}; | ||
| int sum = 0; | ||
|
|
||
| for (int num : arr) { | ||
| sum += num; | ||
| } | ||
|
|
||
| //예상 결과 : sum=150 | ||
| System.out.println("sum="+sum); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| package jeondabeen.report4; | ||
|
|
||
| public class Report4_4 { | ||
| public static void main(String[] args) { | ||
| int[][] arr = { | ||
| { 5, 5, 5, 5, 5 }, | ||
| { 10, 10, 10, 10, 10 }, | ||
| { 20, 20, 20, 20, 20 }, | ||
| { 30, 30, 30, 30, 30 } | ||
| }; | ||
|
|
||
| int total = 0; | ||
| float average = 0; | ||
|
|
||
| int numCount = 0; | ||
| for (int[] ints : arr) { | ||
| for (int num : ints) { | ||
| total += num; | ||
| numCount++; | ||
| } | ||
| } | ||
|
|
||
| average = (float) total / numCount; | ||
|
|
||
| System.out.println("total=" + total); | ||
| System.out.println("average=" + average); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| package jeondabeen.report4; | ||
|
|
||
| import java.util.Arrays; | ||
|
|
||
| public class Report4_5 { | ||
| public static void main(String[] args) { | ||
| int[] ballArr = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; | ||
| int[] ball3 = new int[3]; | ||
|
|
||
| // 배열 ballArr의 임의의 요소를 골라서 위치를 바꾼다 | ||
| for (int i = 0; i < ballArr.length; i++) { | ||
| int j = (int) (Math.random() * ballArr.length); | ||
| int tmp = 0; | ||
|
|
||
| tmp = ballArr[i]; | ||
| ballArr[i] = ballArr[j]; | ||
| ballArr[j] = tmp; | ||
| } | ||
|
|
||
| for (int i = 0; i < 3; i++) { | ||
| ball3[i] = ballArr[i]; | ||
| } | ||
|
|
||
| // 배열 ballArr의 앞에서 3개의 수를 배열 ball3로 복사한다 | ||
| ball3 = Arrays.copyOf(ballArr, 3); | ||
|
|
||
| for (int i = 0; i < ball3.length; i++) { | ||
| System.out.print(ball3[i]); | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
좋습니다!