Recent Posts
printf("ho_tari\n");
GenderRatio (static_cast) 본문
#include <stdio.h>
int main(void)
{
int man, woman;
printf("Man: ");
scanf("%d", &man);
printf("Woman: ");
scanf("%d", &woman);
double manratio, womanratio;
manratio = static_cast<double>(man) / (man + woman) * 100;
womanratio = static_cast<double>(woman) / (man + woman) * 100;
printf("----------------------------\n");
printf("Ratio of Man : %.2f%%\nRatio of Woman : %.2f%%\n", manratio, womanratio);
return 0;
}
<compile 결과>
'C++' 카테고리의 다른 글
Shape (dynamic_cast) (0) | 2023.09.08 |
---|---|
Pointer3 (reinterpret_cast) (0) | 2023.09.08 |
SafeArray4 (try, throw, catch) (0) | 2023.09.08 |
BoundArray2 (template 사용) (0) | 2023.09.08 |
SafeArray3 (template 사용) (0) | 2023.09.08 |