목록분류 전체보기 (351)
printf("ho_tari\n");
#include #include long long power(int base, int exponent) { long long result = 1; for (int i = 0; i < exponent; ++i) { result *= base; } return result; } int main(void) { int base = 2; int exponent = 10; long long result = power(base, exponent); printf("%d^%d = %lld\n", base, exponent, result); return 0; }
#include long long power(int base, int exponent) { long long result = 1LL; for (int i = 1; i
#include #include "empty.h" int main() { Empty e1; const Empty e2 = e1; e1 = e2; Empty *p1 = &e1; // e1.operator&() const Empty *p2 = &e2; // e2.operator&() return 0; } #ifndef EMPTY_H #define EMPTY_H class Empty { public: //Empty() { } //Empty(const Empty& rhs) { /* memberwise copy */ } //~Empty() { } //Empty& operator=(const Empty& rhs) { /* memberwise copy */ } //Empty *operator&() { return t..
#include int main(void) { int num; scanf("%d", &num); if (num > 0) { printf("%d is a positive number\n", num); } else if (num == 0) { printf("%d is zero number\n", num); } else { printf("%d is a negative number\n", num); } return 0; } #include int main(void) { int num; scanf("%d", &num); /* if (num > 0) { printf("%d is a positive number\n", num); } else if (num == 0) { printf("%d is zero number\..
#include int main(void) { int nums[] = {1, 2, 3, 4, 5}; int *p; p = nums; for (int i = 0; i < 5; ++i) { printf("%d ", nums[i]); } printf("\n"); for (int i = 0; i < 5; ++i) { printf("%d ", *(nums + i)); } printf("\n"); for (int i = 0; i < 5; ++i) { printf("%d ", *(p + i)); } printf("\n"); for (int i = 0; i < 5; ++i) { printf("%d ", p[i]); } printf("\n"); return 0; }
#include int main(void) { int nums[] = {1, 2, 3, 4, 5}; int *p; p = nums; // p = &nums[0]; printf("*p = %d\n", *p); ++p; // p = p + 1; printf("*p = %d\n", *p); p = nums; printf("*(p + 2) : %d\n", *(p + 2)); return 0; }