-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComplex.cpp
More file actions
86 lines (80 loc) · 1.72 KB
/
Complex.cpp
File metadata and controls
86 lines (80 loc) · 1.72 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
77
78
79
80
81
82
83
84
85
86
#include<bits/stdc++.h>
using namespace std;
struct Complex {
// your code goes here
// Cac bien thanh vien
// your code goes here
// Hai ham khoi tao
int a;
int b;
Complex(){};
Complex(int a,int b){
this->a=a;
this->b=b;
}
double abs() {
return sqrt(pow(a,2)+pow(b,2))*1.0;
}
void print() {
if(a==0&&b==0){
cout<<0<<endl;
}
else{
if(a==0){
if(b<0){
if(b==-1)
cout<<"-"<<"i"<<endl;
else
cout<<'-'<<b*-1<<"i"<<endl;
}
else if(b>0){
if(b==1)
cout<<"i"<<endl;
else
cout<<b<<"i"<<endl;}
}
else if(b==0){
cout<<a<<endl;
}
else{
if(b<0){
if(b==-1)
cout<<a<<"-"<<"i"<<endl;
else
cout<<a<<'-'<<b*-1<<"i"<<endl;}
else if(b>0){
if(b==1)
cout<<a<<"+"<<"i"<<endl;
else
cout<<a<<"+"<<b<<"i"<<endl;}
}
}
}
};
Complex add(Complex x, Complex y) {
int m=x.a+y.a;
int n=x.b+y.b;
Complex z(m,n);
return z;
}
int main(){
int n;
cin>>n;
int odd=0;
int sum=0;
vector<int> a(n+1);
for(int i=0;i<=n;i++){
cin>>a[i];
}
sort(a.begin(),a.end());
for(int i=0;i<=n;i++){
if(a[i]%2==0)
sum+=a[i];
else
odd++;
}
cout<<a[0]<<endl;
cout<<a[n]<<endl;
cout<<sum<<endl;
cout<<odd;
}