#includeusing namespace std; struct Complex { double real; double imaginary; }; int add(int , int); double add(double , double); Complex add(Complex , Complex); int main() { int i = 1 , j = 2; double m = 1.0 , n = 2.0; Complex a , b; a.imaginary = 1.0 , a.real = 1.0; b.imaginary = 1.0 , b.real = 1.0; cout<<"输入i , j"< >i>>j; int k = add(i , j); cout<<"a + b = "< < >m>>n; double s = add(m , n); cout<<"m + n = "< <>a.imaginary>>a.real; cout<<"输入b的imaginary和real值:"< >b.imaginary>>b.real; // cout<<"a + b = "<
运行结果
2
#includeusing namespace std;void qa(int a[],int n){ int i=0,j=n-1; int m=a[0]; if(n<=1) { return ; }while(i i;j--){ if(a[j] m) { a[j--]=a[i]; break; } } } a[i]=m; qa(a,i); qa(a+i+1,n-i-1);}
#includeusing namespace std;void qa(int a[],int n){ int i=0,j=n-1; int m=a[0]; if(n<=1) { return ; } while(i i;j--) { if(a[j] m) { a[j--]=a[i]; break; } } } a[i]=m; qa(a,i); qa(a+i+1,n-i-1);}int main(void){ int b[10]; int i=0; cout<<"输入:"; for(i=0;i<10;i++) { cin>>b[i]; } qa(b,10); cout<<"输出: "; for(i=0;i<10;i++) cout<<" "<
运行结果
3
#include#include #include using namespace std;class User{public: void setInfo(string name1 , string passwd1 , string email1); int setInfo(string name1); void changePasswd(); void printInfo();private: string name; string passwd; string email;};void User::setInfo(string name1 , string passwd1 , string email1){ name.assign(name1); passwd.assign(passwd1); email.assign(email1);}int User::setInfo(string name1) { name.assign(name1); email.assign(""); passwd.assign("111111"); return 0;}void User::changePasswd(){ string oldpassword; string passwd1; cout<<"原密码: "< >oldpassword; int n = 1; while(oldpassword != passwd) { if(n < 3) { int i = 3 - n; cout<<"错误,请重新输入密码"< >oldpassword; n++; } else { cout<<"验证失败,请稍后再试,暂时退出修改密码程序"< >passwd1; passwd.assign(passwd1); return;}void User::printInfo(){ cout<<"用户名: "< <
运行结果