-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvectorandalgorithm.cpp
More file actions
43 lines (43 loc) · 1.08 KB
/
vectorandalgorithm.cpp
File metadata and controls
43 lines (43 loc) · 1.08 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
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
//vector<string> kisiler;
//kisiler.push_back("mustafa koca");
//kisiler.push_back("halil kantek");
//kisiler.push_back("eray gokagac");
//for(auto current : kisiler){
// cout<<current<<endl;
//}
//sort(kisiler.begin(), kisiler.end());
//for(auto current:kisiler){
// cout<<current<<endl;
//}
//return 0;
int arr[]={10,20,0,5,23,42,15};
int n=sizeof(arr)/sizeof(arr[0]);
vector<int> v(arr,arr+n);
cout<<"vector: ";
for(int i=0; i<n; i++){
cout<<v[i]<<" ";
}
sort(v.begin(),v.end());
cout<<"\nsiralamadan sonra vector: ";
for(int i=0;i<n;i++){
cout<<v[i]<<" ";
}
reverse(v.begin(),v.end());
cout<<"\nterse yazilmis sirali vector: ";
for(int i=0;i<6;i++){
cout<<v[i]<<" ";
}
cout<<"\nmaximum: ";
cout<<*max_element(v.begin(),v.end());
cout<<"\nminimum: ";
cout<<*min_element(v.begin(),v.end());
//cout<<"vector elemanlarinin toplami: ";
//vector toplama komutu
//cout<<accumulate(v.begin(),v.end(),0);
return 0;
}