옵션 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | #include <iostream> void swap(int *a, int *b) { int temp; temp = *b; *b = *a; *a = temp; } void swap(char *a, char *b) { char temp; temp = *b; *b = *a; *a = temp; } void swap(double *a, double *b) { double temp; temp = *a; *b = *a; *a = temp; } int main10(void) { int num1 = 20, num2 = 30; swap(&num1, &num2); std::cout << num1 << ' ' << num2 << std::endl; char ch1='A', ch2='Z'; swap(&ch1, &ch2); std::cout << ch1 << ' ' << ch2 << std::endl; double dbl1 = 1.111, dbl2 = 5.555; swap(&dbl1, &dbl2); std::cout << dbl1 << ' ' << dbl2 << std::endl; return 0; } | cs |