Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions 17EGICS021_ARRAY-1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
int n,a[n],i;
cout<<"Enter the Size of array\n";
cin>>n;
cout<<"Enter elements\n";
for(i=0;i<n;i++)
cin>>a[i];

sort(a,a+n);
int count1=1,count2=1,t=a[0];
for(i=0;i<n;i++)
{
if(a[i]==a[i-1])
count1++;
else
{
if(count1>count2)
{
count2=count1;
t=a[i-1];
}
count1=1;
}
}

if(count1>count2)
{
count2=count1;
t=a[n-1];
}
cout<<"\nans : "<<t;
}
44 changes: 44 additions & 0 deletions 17EGICS021_ARRAY-2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
int n,a[n],i;
cout<<"Enter the Size of array\n";
cin>>n;
if(n%2==0)
{
cout<<"Enter elements\n";
for(i=1;i<=n;i++)
cin>>a[i];

int min1=1,max1=n/2,min2=(n/2)+1,max2=n,s1=0,s2=0;

for(i=min1;i<=max1;i++)
{
s1+=a[i];

}

for(i=min2;i<=max2;i++)
{
s2+=a[i];

}

if(s1<s2)
{
cout<<"\n!st have min sum = "<<s1;
}
else
cout<<"\n2nd have min sum = "<<s2;

}
else
{
cout<<"Please Enter even size of array\n";
}

}