Skip to content

Commit dc8b983

Browse files
authored
Create example_optimal.cpp
1 parent 0400be0 commit dc8b983

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

example_optimal.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// NOTE this file show you how one can replicate one code into my templaate
2+
3+
#include "h1.h" //manadatory don't remove it !!
4+
5+
int summ(int n)
6+
{
7+
int sum = 0;
8+
while (n != 0) {
9+
sum = sum + n % 10;
10+
n = n / 10;
11+
}
12+
return sum;
13+
}
14+
15+
16+
_s //manadatory don't remove it !!
17+
18+
int n1;
19+
cin>>n1;
20+
int s=summ(n1);
21+
if(s%2==0)
22+
{
23+
if(summ(n1+1)%2==0)
24+
cout<<n1+2 lc; //notice we have added lc which is defined as <<"\n" in ```h1.h``` we need to do because user has putted ```endl``` after callling solve function
25+
else
26+
cout<<n1+1 lc; //notice we have added lc which is defined as <<"\n" in ```h1.h``` we need to do because user has putted ```endl``` after callling solve function
27+
}
28+
else
29+
{
30+
if(summ(n1+1)%2==0)
31+
cout<<n1+1 lc; //notice we have added lc which is defined as <<"\n" in ```h1.h``` we need to do because user has putted ```endl``` after callling solve function
32+
else
33+
cout<<n1+2 lc; //notice we have added lc which is defined as <<"\n" in ```h1.h``` we need to do because user has putted ```endl``` after callling solve function
34+
}
35+
36+
_2 //manadatory don't remove it !!
37+
38+
//notice we have used _2 instead of _1 since we have one or more test cases to be tested

0 commit comments

Comments
 (0)