include stdafx include math include iostream using namespace std void

 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
38
39
#include "stdafx.h"
#include "math.h"
#include <iostream>
using namespace std;
void f (int n)
{
while (n!=0)
{
if(n-1000>0) { cout<<"M"; n=n-1000;}
else if(n-500>0) { cout<<"D"; n=n-500;}
else if(n-100>0) { cout<<"C"; n=n-100;}
else if(n-50>0) { cout<<"L"; n=n-50;}
else if(n-10>0) { cout<<"X"; n=n-10;}
else if(n-9>0) { cout<<"IX"; n=n-9;}
else if(n-8>0) { cout<<"VIII"; n=n-8;}
else if(n-7>0) { cout<<"VII"; n=n-7;}
else if(n-6>0) { cout<<"VI"; n=n-6;}
else if(n-5>0) { cout<<"V"; n=n-5;}
else if(n-4>0) { cout<<"IV"; n=n-4;}
else if(n-1>=0) { cout<<"I"; n=n-1;}
}
}
void main()
{ int n;
cin>>n;
f(n);
}