#include<iostream>
using namespace std;
struct Complex
{
double real;
double imaginary;
};
int add(int x,int y)
{
int s;
s=x+y;
cout<<s<<endl;
return 0;
}
double add(double x,double y)
{
double s=x+y;
cout<<s<<endl;
return 0;
}
Complex add(Complex x,Complex y)
{
Complex s;
s.real=x.real+y.real;
s.imaginary=x.imaginary+y.imaginary;
cout<<s.real<<"+"<<s.imaginary<<"i"<<endl;
return s;
}
int main ()
{
int a,b;
double c,d;
Complex m,n;
cin>>a>>b;
add(a,b);
cin>>c>>d;
add(c,d);
cin>>m.real;
cin>>m.imaginary;
cin>>n.real;
cin>>n.imaginary;
add(m,n);
return 0;
}
![]()
#include<iostream>
using namespace std;
template <typename T>
void Swap(T &x,T &y)
{
T m;
m=x;
x=y;
y=m;
}
template <typename T>
void QuickSort(T a[],int low,int high)
{
int i=low;
int j=high;
int key=a[low];
if (low>=high)
{
return ;
}
while (low<high)
{
while (low<high&&a[high]>=key)
{
high--;
}
if (a[high]<key)
{
Swap(a[low],a[high]);
low++;
}
while (low<high&&a[low]<=key)
{
low++;
}
if (a[low]>key)
{
Swap(a[low],a[high]);
high--;
}
}
QuickSort(a,i,low-1);
QuickSort(a,low+1,j);
}
int main ()
{
int a[]={9,2,-58,34,5,76,9,1,56,2500};
double b[]={2.3,45.3,1.3,4,53,13,3.2,9,48.6,10};
QuickSort(a,0,9);
QuickSort(b,0,9);
for (int i=0;i<10;i++)
{
cout<<a[i]<<" ";
}
cout<<endl;
for (int i=0;i<10;i++)
{
cout<<b[i]<<" ";
}
cout<<endl;
return 0;
}
![]()
#include<iostream>
#include<String>
using namespace std;
class User
{
public:
User (string name,string password,string email)
{
username=name;
userpassword=password;
useremail=email;
}
void setinfo (string name,string password,string email)
{
username=name;
userpassword=password;
useremail=email;
}
void printinfo()
{
cout<<username<<"\t"<<"******"<<"\t"<<useremail<<endl;
}
void changepassword()
{
int i;
for (i=0;i<3;i++)
{
cout<<"please enter the old password:"<<endl;
cin>>enterpassword;
if (enterpassword==userpassword)
break;
else
continue;
}
if (i!=3)
{
cout<<"please enter the newpassword"<<endl;
cin>>usernewpassword;
setinfo(username,usernewpassword,useremail);
}
else
{
cout<<"please try later"<<endl;
exit(0);
}
}
private:
string username,useremail;
string userpassword,usernewpassword;
string enterpassword;
};
int main ()
{
User myuse("","111111","");
myuse.setinfo("libing","072921","2030950866@qq.com");
myuse.printinfo();
myuse.changepassword();
cout<<"the user after change:"<<endl;
myuse.printinfo();
return 0;
}
![]()
![]()