이 튜토리얼에서는 1년 동안 세기를 찾는 프로그램에 대해 논의할 것입니다.
이를 위해 1년이 제공됩니다. 우리의 임무는 주어진 연도가 속하는 세기를 찾는 것입니다.
예시
#include <bits/stdc++.h>
using namespace std;
void find_century(int year){
//year values can only be positive
if (year <= 0)
cout << "0 and negative is not allow"
<< "for a year";
else if (year <= 100)
cout << "1st century\n";
else if (year % 100 == 0)
cout << year/ 100 <<" century";
else
cout << year/ 100 + 1 << " century";
}
int main(){
int year = 2001;
find_century(year);
return 0;
} 출력
21 century