728x90 배열3 [C언어] 자료구조 - 포인터,배열,malloc 모든 변수는 주소를 가진다. 포인터(pointer) : 메모리 주소를 값으로 가지는 변수 int *ptr; & : 주소 추출 int c = 10; int *p; p = &c; //변수 c가 저장되어있는 메모리주소를 p에 넣음 int x = 1; int y = 1; int *ip; ip = &x; //x의 주소값1003가 ip에 저장됨. y = *ip; //ip에 있던 1003의 주소값을 가진 x값, 즉 1이 y에 저장됨. *ip = 0; //x가 0으로 됨. 1003 1 x 1004 1 y 1005 1006 1003 ip 1007 배열의 이름은 배열의 첫번째 값을 저장하는 포인터 int calculateSum(int *array) int함수에서 배열을 매개변수로 넘겨줄 때, 포인터 사용 가능 array[.. 2020. 7. 17. [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. 이전 1 다음 728x90