본문 바로가기

프로그래밍 C13

C언어 최댓값구하기 코드 #include #include #include #define SIZE 10 int main(void) { int prices[SIZE] = { 0 }; int i, maximum; printf("--------------------------------------\n"); printf("1 2 3 4 5 6 7 8 9 10\n"); printf("--------------------------------------\n"); srand((unsigned)time(NULL)); for (i = 0; i < SIZE; i++) { prices[i] = rand() % 1001; printf("%-2d ", prices[i]); } printf("\n\n"); maximum = prices[0]; for (i.. 2020. 11. 11.
C언어 최솟값구하기 코드 #include #include #include #define SIZE 10 int main(void) { int prices[SIZE] = { 0 }; int i, minimum; printf("---------------------------------\n"); printf("1 2 3 4 5 6 7 8 9 10\n"); printf("---------------------------------\n"); srand((unsigned)time(NULL)); for (i = 0; i < SIZE; i++) { prices[i] = rand() % 1000 + 1; printf("%-2d ", prices[i]); } printf("\n\n"); minimum = prices[0]; for (i = 1; .. 2020. 11. 11.
쉽게 풀어쓴 C언어 익스프레스 10장 프로그래밍 6번 #include #include #include #define ROW 3 #define COL 3 int main(void) { int r, c; srand((unsigned)time(NULL)); int A[ROW][COL]; for (r = 0; r < ROW; r++) for (c = 0; c < COL; c++) { A[r][c] = rand() % 100; //2차원 배열 초기화 } printf("\n배열\n"); for (r = 0; r < 30; r++) printf("="); for (r = 0; r < ROW; r++) { printf("\n"); for (c = 0; c < COL; c++) printf("%d ", A[r][c]); //2차원 배열 출력 } printf("\n"); f.. 2020. 1. 7.
쉽게 풀어쓴 C언어 익스프레스 프로그래밍 5번 rearranged version #include #include #include #define SIZE 100 #define Z 6 int largeone(int *freq); int one(int *freq, int max); int main(int large,int count) { int i, temp, max = 0; int abc[SIZE] = { 0 }; int freq[Z] = { 0 }; srand((unsigned)time(NULL)); for (i = 0; i 2020. 1. 7.
쉽게 풀어쓴 C언어 익스프레스 10장 프로그래밍 4번 #include #define SIZE 10 void array_copy(int a[], int b[], int size); int main(void) { int a[] = { 1,2,3,4,5,6,7,8,9,10 }; int b[SIZE] = { 0 }; array_copy(a, b, SIZE); return 0; } void array_copy(int a[], int b[], int size) { for (int i = 0; i 2020. 1. 7.
쉽게 풀어쓴 C언어 익스프레스 11장 프로그래밍 6번 #include #define SIZE 10 void array_copy(int *A, int *B, int size); int main(void) { int A[SIZE] = { 1,2,3,0,0,0,0,0,0,0 }; int B[SIZE] = { 0 }; array_copy(A, B, SIZE); return 0; } void array_copy(int *A, int *B, int size) { int i; printf("배열 B:"); for (i = 0; i 2019. 11. 20.
반응형