목록C++ Programming (41)
Creative Code
※main.cpp파일 #include #include "complex.h" using iot::Complex; int main() { iot::Complex c1(3.0,4.0); Complex c2(3.0); Complex c3; const Complex c4 = c1; c2 = c1; c2.real(c1.real()); c2.imag(c1.imag()); std::cout
※main.cpp파일 #include #include "shape.h" #include "rectangle.h" #include "circle.h" #include void printArea(Shape *ps) { std::cout
※main.cpp파일 #include #include "string.h" int main() { String s1; String s2 = "hello, world"; // String s2("hello,world"); //String s2 = 0;// NULL String s3 = s2; // String s3(s2); s1 = s2; String s4 = " IoT"; s1 = s2 + s4; s1 = "hello, "; //String tmp("hello, "); if (s1 == s2) std::cout
#include int main(void) { int a = 0x12345678; char *p; //p = (char*) &a; p = reinterpret_cast(&a); //강제 형 변환 static_cast가 안될 때 printf("*p : 0x%x\n",*p); return 0; }
#include int main(void) { int men, women; printf("남자 수 : "); scanf("%d",&men); printf("여자 수 : "); scanf("%d",&women); int total = men + women; //double ratiom = 1.0 * men/total * 100; //double ratiow =1.0 * women/total * 100; double ratiom = static_cast(men)/(double)(total) * (double) 100; //static_cast double ratiow = static_cast(women)/(total) * 100; printf("남자 비율 : %.2f%%\n",ratiom); printf("..