diff --git a/code_study/data_structure/DS_array.c b/code_study/data_structure/DS_array.c new file mode 100644 index 0000000..05ab4e5 --- /dev/null +++ b/code_study/data_structure/DS_array.c @@ -0,0 +1,13 @@ +#include + +int main(){ + int numbers[10] = {5, 29, -10, 55, 1, 9, 8, 15, 42, -7}; + int min = numbers[0], max = numbers[0]; + for(int i=0; i<10; i++){ + if(numbers[i]max) max = numbers[i]; + } + + printf("최소값 : %d\n최대값 : %d\n to. 리노",min, max); + return 0; +} \ No newline at end of file diff --git a/code_study/data_structure/DS_array.java b/code_study/data_structure/DS_array.java new file mode 100644 index 0000000..a23c27a --- /dev/null +++ b/code_study/data_structure/DS_array.java @@ -0,0 +1,23 @@ +import java.util.*; + +public class DS_array { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + ArrayList numbers = new ArrayList<>(); + String[] input = sc.nextLine().split(" "); + sc.close(); + for(String num : input){ + numbers.add(Integer.parseInt(num)); + } + + int min = numbers.get(0); + int max = numbers.get(0); + for(int num : numbers){ + min = Math.min(min, num); + max = Math.max(max, num); + } + + System.out.printf("To. Rino\n최소값 : %d\n최대값 : %d\nFrom. 한심한 예찬..\n",min,max); + + } +} diff --git a/code_study/data_structure/DS_array.py b/code_study/data_structure/DS_array.py new file mode 100644 index 0000000..a247be7 --- /dev/null +++ b/code_study/data_structure/DS_array.py @@ -0,0 +1,9 @@ +numbers = list(map(int, input().split())) +min_value = max_value = numbers[0] + +for num in numbers: + min_value = num if num < min_value else min_value + max_value = num if num > max_value else max_value + +result = "To. 건방진 리노\n최소값: " + str(min_value) + "\n최대값: " + str(max_value) + "\nFrom. 조금은 너와 가까워지고픈 예찬" +print(result) \ No newline at end of file diff --git a/code_study/data_structure/DS_array.swift b/code_study/data_structure/DS_array.swift new file mode 100644 index 0000000..4b34e89 --- /dev/null +++ b/code_study/data_structure/DS_array.swift @@ -0,0 +1,19 @@ +if let input = readLine(), + let numbers = { + let tempNumbers = input.split(separator: " ").compactMap({Int($0)}) + return tempNumbers.isEmpty ? nil : tempNumbers + }() { + + var min = numbers[0] + var max = numbers[0] + + for num in numbers { + min = min > num ? num : min + max = max < num ? num : max + } + + print("To. Cuty Rino\n최소값 : \(min)\n최대값 : \(max)\n") + +} else { + print("좀 더 노력할게.. 리노야...") +} diff --git a/code_study/data_structure/DS_array.ts b/code_study/data_structure/DS_array.ts new file mode 100644 index 0000000..46b32f9 --- /dev/null +++ b/code_study/data_structure/DS_array.ts @@ -0,0 +1,9 @@ +const numbers: number[] = require("fs").readFileSync(0, "utf8").toString().split(' ').map(Number); +let [min, max]: number[] = [numbers[0], numbers[0]] + +for(let num of numbers){ + min = min > num ? num : min; + max = max < num ? num : max; +} + +console.log(min, max); \ No newline at end of file