-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathclassArrayMinMaxSort.cpp
More file actions
76 lines (74 loc) · 1.41 KB
/
classArrayMinMaxSort.cpp
File metadata and controls
76 lines (74 loc) · 1.41 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include<iostream>
using namespace std;
class arr
{
int a[10];
public:
void set_data(int x,int i)
{
a[i]=x;
}
void max_value(int n)
{
int m;
m=a[0];
for(int i=0;i<n;i++)
{
if(m<a[i])
m=a[i];
}
cout<<"Maximum value is : "<<m;
}
void min_value(int n)
{
int m;
m=a[0];
for(int i=0;i<n;i++)
{
if(m>a[i])
m=a[i];
}
cout<<"\nMinimum value in array is : "<<m;
}
void sort_value(int n)
{
for(int i=0;i<n-1;i++)
{
for(int j=i+1;j<n;j++)
{
if(a[i]<a[j])
{
int temp;
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
cout<<endl<<"The descending order is : ";
for(int i=0;i<n;i++)
{
cout<<a[i]<<" ";
}
}
};
int main()
{
void set_data(int);
void max_value(int);
void min_value(int);
void sort_value(int);
arr a1;
int n,t;
cout<<"How many value do you want to enter? :: ";
cin>>n;
cout<<"Enter element : ";
for(int i=0;i<n;i++)
{
cin>>t;
a1.set_data(t,i);
}
a1.max_value(n);
a1.min_value(n);
a1.sort_value(n);
}