회원가입
로그인
Toggle navigation
문제
문제
전체 문제
문제 출처
단계별로 풀어보기
알고리즘 분류
추가된 문제
문제 순위
문제
푼 사람이 한 명인 문제
아무도 못 푼 문제
최근 제출된 문제
최근 풀린 문제
랜덤
출처
ICPC
Olympiad
한국정보올림피아드
한국정보올림피아드시․도지역본선
전국 대학생 프로그래밍 대회 동아리 연합
대학교 대회
카카오 코드 페스티벌
Coder's High
ICPC
Regionals
World Finals
Korea Regional
Africa and the Middle East Regionals
Europe Regionals
Latin America Regionals
North America Regionals
South Pacific Regionals
문제집
대회
채점 현황
게시판
그룹
더 보기
재채점 기록
블로그
도움말
전체
공지
자유
질문
오타/오역/요청
게시판 공지
홍보
업데이트
solved.ac
글쓰기
질문 도움말
자주묻는 질문
이게 왜 틀린거쥬??
1340번 - 연도 진행바
hooss
2년 전
0
억 뭐여 이거 틀렸잖아?
지는 잘 모르겄구먼유
#include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <string.h> bool check_leap(int year) { return (year % 4 == 0 && year % 100 != 0 || year % 400 == 0); } int get_days_in_month(int year, int month) { if (month == 2) return check_leap(year) ? 29 : 28; if (month <= 7) return month % 2 == 0 ? 30 : 31; return month % 2 == 0 ? 31 : 30; } int get_days_off_by_date(int year, int month, int day) { int days = 0; for (int i=1; i<month; i++) { days += get_days_in_month(year, i); } days += day - 1; return days; } int get_whole_days(int year) { return check_leap(year) ? 366 : 365; } int get_month_by_name(char *month_name) { char *month_names[] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December", }; for (int i=0; i<12; i++) { if (!strcmp(month_name, month_names[i])) return i+1; } return -1; } int main() { char year_str[10]; char month_name[20]; char day_str[10]; char time_str[10]; scanf("%s %s %s %s", month_name, day_str, year_str, time_str); day_str[2] = 0; /* CHANGE STRING TO INTAGER */ int year, month, day, hour, min; year = atoi(year_str); day = atoi(day_str); month = get_month_by_name(month_name); // separate time_str to hour and min char hour_str[3] = { time_str[0], time_str[1], 0 }; char min_str[3] = { time_str[3], time_str[4], 0 }; hour = atoi(hour_str); min = atoi(min_str); /* CONVERT TO PERCENTAGE */ int whole_days = get_whole_days(year); float minute_percentage = min / 60.0; float hour_percentage = hour / 24.0; float days_percentage = get_days_off_by_date(year, month, day) / (float) whole_days; hour_percentage += minute_percentage * (1/24.0); days_percentage += hour_percentage * (1/(float) whole_days); printf("%.10f\n", days_percentage*100); return 0; }
댓글을 작성하려면
로그인
해야 합니다.
hooss 2년 전
억 뭐여 이거 틀렸잖아?
지는 잘 모르겄구먼유