-
Notifications
You must be signed in to change notification settings - Fork 0
/
int_count_breakdown.cpp
113 lines (64 loc) · 1.19 KB
/
int_count_breakdown.cpp
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
int a[] = {2,5,4,5,6,8,9,2,5,4,7,7,3};
vector<int> nums(a, a + sizeof(a)/sizeof(int));
sort(nums.begin(), nums.end());
for(int i = 0; i < nums.size();i++)
{
cout << nums[i];
}
cout << endl;
vector<int> ct;
int temp = nums[0];
int c = 0;
vector<int> v;
v.push_back(nums[0]);
cout << "nums szie = " << nums.size() << endl;
int i =0;
while(i < nums.size())
{
while( nums[i] == temp )
{
c++;
i++;
}
cout << "i AFTER while loop = " << i << endl;
cout << "nums" << nums[i] << endl;
v.push_back(nums[i]);
ct.push_back(c);
c = 0;
temp = nums[i];
}
for(int i = 0; i < v.size(); i++)
{
cout <<v[i];
}
cout << endl;
for(int i = 0; i < ct.size(); i++)
{
cout << ct[i];
}
cout << endl;
/*
sort(nums.begin(),nums.end());
vector<int> val;
vector<int> count;
int n=nums.size();
for(int i=0;i<nums.size();i++)
{
val.push_back(nums[i]);
int c=1;
while((i+1)<n && nums[i+1]==nums[i])
{
c++;
i++;
}
count.push_back(c);
}
*/
return 0;
}