-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgraph.cpp
More file actions
65 lines (57 loc) · 1.18 KB
/
graph.cpp
File metadata and controls
65 lines (57 loc) · 1.18 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
#include<iostream>
using namespace std;
void plot(int ar[], int n)
{
int highest=0;
for(int i=0; i<n; i++)
{
if(ar[i]>highest)
highest=ar[i];
}
cout<<endl;
for(int c=highest;c> 0;c--)
{
if(highest<10)
{
cout<<"\t\t";
cout<<" "<<highest<<"-|";
cout<<"\t";
}
else
{
cout<<"\t\t";
cout<<highest<<"-|";
cout<<"\t";
}
for(int r=0;r<n;r++)
{
if(ar[r]<highest)
cout<<"\t";
if(ar[r]>=highest)
cout<<"|##|\t";
}
highest--;
cout<<endl;
}
cout<<"\t\t___|_________";
for(int k=n;k>0;k--)
cout<<"________";
cout<<endl;
cout<<"\t\t\t ";
for(int k=0;k<n;k++)
cout<<k+1<<" ";
cout<<"\n\n";
}
int main()
{
cout<<"Enter the total no. of data entries : ";
int n;
cin>>n;
int ar[n];
for(int i=0; i<n; i++)
{
cout<<"\nEnter the value of no."<<i+1<<" element : ";
cin>>ar[i];
}
plot(ar,n);
}