목록C (66)
printf("ho_tari\n");
#include #include "square.h" #define SQUARE(num) (num) * (num) /* int square(int num) { return num * num; } */ int main(void) { //int result = square(5); //int result = SQUARE(5); // int result = (5) * (5); int i = 5; int result = square(i++); //int result = SQUARE(i++); // int result = (i++) * (i++); printf("result : %d\n", result); return 0; } #ifndef SQUARE_H #define SQUARE_H extern inline in..
#include #define SQUARE(num) (num) * (num) int square(int num) { return num * num; } int main(void) { //int result = square(5); //int result = SQUARE(5); // int result = (5) * (5); int i = 5; //int result = square(i++); int result = SQUARE(i++); // int result = (i++) * (i++); printf("result : %d\n", result); return 0; }
#include #include int main(void) { int size; scanf("%d", &size); //int array[size]; // ??? int *pArr = malloc(sizeof(int) * size); if (pArr == NULL) { fprintf(stderr, "can't malloc()\n"); exit(1); } for (int i = 0; i < size; ++i) { pArr[i] = i + 1; } for (int i = 0; i < size; ++i) { printf("%d\n", pArr[i]); } free(pArr); return 0; }
#include int main(void) { int w; int h; printf("width : "); scanf("%d", &w); printf("height : "); scanf("%d", &h); double area; area = w * h * 0.5; printf("-----------------------\n"); printf("Triangle Area : %.1f\n", area); return 0; }
#include int main(void) { int a, b; a = 100; b = 200; printf("a: %d\tb: %d\n", a, b); //swap int tmp = a; a = b; b = tmp; printf("a: %d\tb: %d\n", a, b); return 0; } #include /* void swap(int a, int b) { int tmp = a; a = b; b = tmp; } */ void swap(int *pa, int *pb) { int tmp = *pa; *pa = *pb; *pb = tmp; } int main(void) { int a, b; a = 100; b = 200; printf("a: %d\tb: %d\n", a, b); swap(&a, &b); ..
#include int main(void) { int matrix[3][4] = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}}; // {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; int total = 0; for (int i = 0; i < 3; ++i) { for (int j = 0; j < 4; ++j) { total += matrix[i][j]; } } printf("sum: %d\n", total); return 0; } #include int sumMatrix(const int (*pMatrix)[4], int row, int col) { int total; for (int i = 0; i < row; ++i) { for (int ..