- Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathinterface.cpp
More file actions
Latest commit
33 lines (31 loc) · 654 Bytes
/
Copy pathinterface.cpp
File metadata and controls
33 lines (31 loc) · 654 Bytes
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
#include<cmath>
#include<cstdio>
#include<vector>
#include<iostream>
#include<algorithm>
#include<string>
usingnamespacestd;
classAdvancedArithmetic{
public:
virtualintdivisorSum(int n)=0;
};
classCalculator : publicAdvancedArithmetic{
intdivisorSum(int n)
{
int t=0,i;
for(i=1;i<=n;i++)
{
if(n%i == 0)
t += i;
}
return t;
}
};
intmain(){
int n;
cin >> n;
AdvancedArithmetic *myCalculator = newCalculator();
int sum = myCalculator->divisorSum(n);
cout << "I implemented: AdvancedArithmetic\n" << sum <<endl;
return0;
}