본문 바로가기
728x90

컴퓨터공학4

[java] charAt(), indexOf()메소드 이용하는 프로그램 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 import java.util.Scanner; public class IndexOfTest { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); String s; System.out.println("문장입력 : "); s = sc.next(); int index = s.indexOf("A"); //A가 몇번째에 있는지 반환(정수형) char c = s.charAt(0); //0번째 문자를 반환(캐릭터형) if (index == -1) Syste.. 2019. 10. 25.
[C언어] 두 배열의 합집합, 교집합, 차집합 구하는 함수 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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 12.. 2019. 10. 18.
[C언어] 포인터 사용하여 배열 이어붙이기,정렬확인,비교 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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 #include int stringCompare(const char *s1, const char *s2) { while (*s1 || *s2) { if(*s1 != *s2) { if(*s1 > *s2) return -1; else return 1; } s1++; s2++; } return 0; } void stringCat(char *s1, const char *s2) { while (*s1) s1.. 2019. 10. 15.
java - Double형 배열과 출력(toString(),for-each) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 import java.util.*; public class Assignment4_1 { public static void main(String[] args) { // TODO Auto-generated method stub double[] arr = {1.0, 2.0, 3.0, 4.0}; double total = 0.0; double max = 0.0; System.out.print("toString()으로 출력 : "); System.out.println(Arrays.toString(arr)); for (double value : arr) { System.out.print(value+" "); .. 2019. 10. 9.
728x90