File tree Expand file tree Collapse file tree 2 files changed +65
-0
lines changed Expand file tree Collapse file tree 2 files changed +65
-0
lines changed Original file line number Diff line number Diff line change 1+ #include < iostream>
2+ using namespace std ;
3+
4+ void printactivity (int s[],int f[],int n)
5+ {
6+ int i=0 ;
7+ int temp=f[i];
8+ cout<<" activity selected is " <<i<<" " ;
9+ for (int j=1 ;j<n;j++)
10+ {
11+ temp=f[i];
12+ if (s[j]>=temp)
13+ {
14+ cout<<j<<" " ;
15+ i=j;
16+ }
17+ }
18+ }
19+ int main ()
20+ {
21+ int s[]={1 ,3 ,0 ,5 ,8 ,5 };
22+ int f[]={2 ,4 ,6 ,7 ,9 ,9 };
23+ int n=(sizeof (f)/sizeof (f[0 ]));
24+ printactivity (s,f,n);
25+ }
Original file line number Diff line number Diff line change 1+ /*
2+ written by pankaj kumar.
3+ */
4+ #include < iostream>
5+ #include < vector>
6+ #include < cmath>
7+ #include < set>
8+ #include < algorithm>
9+ #include < string.h>
10+ #define pan cin.tie(0 );cout.tie(0 );ios_base::sync_with_stdio(0 );
11+ #define mod 1000000007 ;
12+ using namespace std ;
13+ typedef long long ll ;
14+ #define line cout<<endl;
15+
16+ void egyptian (int a,int b)
17+ {
18+ if (a==1 )
19+ cout<<" 1/" <<b<<" " ;
20+ else
21+ {
22+ int hcf,temp;
23+ // don't do here.
24+ // temp=ceil(b/a);
25+ temp=ceil (b/(a*1.0 ));
26+ cout<<" 1/" <<temp<<" " ;
27+ hcf=__gcd (a*temp-b,b*temp);
28+ egyptian ((a*temp-b)/hcf,(b*temp)/hcf);
29+ }
30+ }
31+
32+
33+ int main ()
34+ {
35+ pan;
36+ int a,b;
37+ cout<<" Enter two no " ;
38+ cin>>a>>b;
39+ egyptian (a,b);
40+ }
You can’t perform that action at this time.
0 commit comments