목록분류 전체보기 (351)
printf("ho_tari\n");
#include #include "complex.h" int main() { Complex c1(3.0,4.0); // 3.0 + 4.0i Complex c2(3.0); // 3.0 + 0i Complex c3; // 0 + 0i c3.real(c1.real()); c3.imag(c1.imag()); std::cout
#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 ..
#include int sumArray(const int *pArr, int size) //int sumArray(int pArr[], int size) //int sumArray(int pArr[10], int size) { int result = 0; for (int i = 0; i < size; ++i) { result = result + pArr[i]; //*(pArr + i) } return result; } int main(void) { int nums[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; int total = sumArray(nums, 10); // sumArray(&nums[0]) //int total = sumArray(nums + 5, 5); // &nums..