Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 모의 주식
- 사물인터넷
- 이웃한 칸
- 코테
- 주가예측
- 백준
- 프로그래밍
- backend
- java정리
- 코스닥
- 개발
- 개발자
- 프로그램
- 프로그래머스
- 개인프로젝트
- 자바정리
- 코딩독학
- Python
- Project
- 코딩테스트
- 빅데이터
- 풀스택프레임워크
- SNS
- 코딩
- frontend
- 자바독학
- 자바
- java
- C++
- Reflex
Archives
- Today
- Total
Creative Code
genderRatio.cpp(static_cast) 본문
#include <stdio.h>
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<double>(men)/(double)(total) * (double) 100; //static_cast
double ratiow = static_cast<double>(women)/(total) * 100;
printf("남자 비율 : %.2f%%\n",ratiom);
printf("여자 비율 : %.2f%%\n",ratiow);
return 0;
}
'C++ Programming' 카테고리의 다른 글
string4(const_cast) (0) | 2023.09.08 |
---|---|
pointer3.cpp(reinterpret_cast) (0) | 2023.09.08 |
safeArray4(try-throw-catch) (0) | 2023.09.08 |
swap2(template 함수) (0) | 2023.09.08 |
boundArray2(template사용) (0) | 2023.09.08 |