Skip to content

Commit 3a24d5f

Browse files
Add files via upload
1 parent cde779b commit 3a24d5f

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Just simulate the process 10 times
2+
3+
int main()
4+
{
5+
const int NO_OF_YEARS = 10;
6+
int r, D;
7+
vector <int> X(NO_OF_YEARS);
8+
cin >> r >> D >> X[0];
9+
10+
for(int i = 1; i <= NO_OF_YEARS; i++)
11+
{
12+
X[i] = r*X[i - 1] - D;
13+
}
14+
15+
for(int i = 1; i <= NO_OF_YEARS; i++)
16+
{
17+
cout << X[i] << "\n";
18+
}
19+
return 0;
20+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include <iostream>
2+
#include <vector>
3+
4+
using namespace std;
5+
6+
int main()
7+
{
8+
int age, cost;
9+
cin >> age >> cost;
10+
11+
if(age <= 5)
12+
{
13+
cost = 0;
14+
}
15+
else if(age <= 12)
16+
{
17+
cost /= 2;
18+
}
19+
20+
cout << cost << "\n";
21+
return 0;
22+
}

0 commit comments

Comments
 (0)