北京理工大學 - 話題

    2000~2008上機復試試題答案+說明(轉)
    查看(2180) 回復(0)
    huitailang
    • 積分:451
    • 注冊于:2010-08-02
    發表于 2010-12-07 00:24
    樓主
    2000年
    1.輸入任意4個字符(如:abcd),并按反序輸出(如:dcba)
    #include<iostream.h>

    void main()
    {
            char s[5],t[5];
            int i;

            cout<<"請輸入四個字符:";
            cin>>s;
            for(i=0;i<4;i++)
                    t=s[3-i];
            t[4]='\0';
            cout<<"反序后結果為:"<<t<<endl;
    }

    2.設a、b、c均是 0 到 9 之間的數字,abc、bcc是兩個三位數,且有:abc+bcc=532。求滿足條件的所有a、b、c的值。
    說明:本題結果唯一。
    #include<iostream.h>

    void main()
    {
            int a,b,c;
            for(a=1;a<10;a++)
                    for(b=1;b<10;b++)
                            for(c=0;c<10;c++)
                                    if((a*100+b*10+c+b*100+c*10+c)==532)
                                            cout<<"滿足條件的a,b,c為:"<<a<<","<<b<<","<<c<<endl;
    //        cout<<"滿足條件的a,b,c為:3,2,1"<<endl;
    }

    3.一個數如果恰好等于它的各因子(該數本身除外)子和,如:6=3+2+1,則稱其為“完數”;若因子之和大于該數,則稱其為“盈數”。求出2到60之間所有“完數”和“盈數”,并以如下形式輸出: E: e1 e2 e3 ......(ei為完數) G: g1 g2 g3 ......(gi為盈數)
    #include<iostream.h>

    void save(int s[],int x,int flag);
    int fun(int x);

    void main()
    {
            int E[60],G[60];
            int flag,i;

            for(i=6;i<=60;i++)
            {
                    flag=fun(i);
                    if(flag==0)
                            save(E,i,0);
                    else if(flag==1)
                                    save(G,i,1);
            }
            cout<<"E:";
            for(i=0;E!=0;i++)
                    cout<<E<<" ";
            cout<<endl<<"G:";
            for(i=0;G!=0;i++)
                    cout<<G<<" ";
            cout<<endl;
    }

    void save(int s[],int x,int flag)
    {
            static i=0,j=0;

            if(flag==0)
            {
                    s=x;
                    s[i+1]=0;
                    i++;
            }
            else
            {
                    s[j]=x;
                    s[j+1]=0;
                    j++;
            }
    }

    int fun(int x)
    {
            int i,sum=0;

            for(i=1;i<=x/2;i++)
                    if(x%i==0)
                            sum+=i;
            if(sum==x)
                    return 0;
            else if(sum>x)
                    return 1;
            else
                    return -1;
    }
            
    4.從鍵盤輸入4個學生的數據(包括姓名、年齡和成績),并存放在文件sf1上。從該文件讀出這些數據,按成績從高到底排序,并輸出其中成績次高者的所有數據。

    2001年A
    1、編寫程序,計算下列分段函數y=f(x)的值。 y= -x+2.5 0<= x <2 y=2-1.5(x-3)(x-3) 2<= x <4 y=x/2-1.5 4<= x <6
    #include<iostream.h>

    float fun(float x)
    {
            float y;
            if(x>=0&&x<2)
                    y=2.5-x;
            else if(x>=2&&x<4)
                    y=2-1.5*(x-3)*(x-3);
            else if(x>=4&&x<6)
                    y=x/2-1.5;
            return y;
    }

    void main()
    {
            float x;

            cout<<"請輸入x的值:";
            cin>>x;
            while(x<0||x>6)
            {
                    cout<<"非法,請重新輸入:";
                    cin>>x;
            }
            cout<<"結果為:"<<fun(x)<<endl;
    }

    2、編寫程序,讀入一個整數 N。若 N 為非負數,則計算 N 到 2N 之間的整數和;若 N 為一個負數,則求 2N 到 N 之間的整數和。
    說明:用了下公式
    #include<iostream.h>
    #include<math.h>

    void main()
    {
            int N;

            cout<<"請輸入一個整數:";
            cin>>N;
            cout<<N<<"到"<<2*N<<"之間的整數和為:"<<(abs(N)+1)*1.5*N<<endl;
    }

    3、設N是一個四位數,它的 9 倍恰好是其反序數(例如:1234的反序數是4321),求N的值。
    說明:本題結果唯一

    4、N個人圍成一圈順序編號,從1號開始按1、2、3順序報數,報3者退出圈外,其余的人再從1、2、3開始報數,報3的人再退出圈外,依次類推。請按退出順序輸出每個退出人的原序號。要求使用環行鏈表編程。
    說明:約瑟夫環
    #include<iostream.h>
    #include<malloc.h>

    typedef struct node
    {
            int num;
            struct node *next;
    }LNode;

    void main()
    {
            int N,i;
            LNode *head,*p,*q;

            cout<<"請輸入人數:";
            cin>>N;
            p=(LNode*)(malloc(sizeof(LNode)));
            p->num=1;
            head=p;
            for(i=1;i<N;i++)
            {
                    p->next=(LNode*)(malloc(sizeof(LNode)));
                    p=p->next;
                    p->num=i+1;
            }
            p->next=head;
            p=head;

            cout<<"出列順序為:";
            while(p->next!=p)        
            {
                    q=p->next;
                    p=q->next;
                    q->next=p->next;
                    cout<<p->num<<" ";
                    delete p;
                    p=q->next;
            }
            cout<<p->num<<endl;
            delete p;
    }


    2001年B
    1、請輸入高度h,輸入一個高為h,上底邊長為h的等腰梯形(例如h=4,圖形如下)。
    ****
    ******
    ********
    **********
    #include<iostream.h>

    void main()
    {
            int i,j,h;

            cout<<"請輸入h:";
            cin>>h;
            for(i=0;i<h;i++)
            {
                    for(j=0;j<h+i;j++)
                            cout<<"*";
                    cout<<endl;
            }
    }

    2、請編寫一個程序,從鍵盤上輸入n(n的范圍是1~20),求n的階乘。
    #include<iostream.h>

    int fun(int n);

    void main()
    {
            int n;

            cout<<"請輸入n:";
            cin>>n;
            while(n>20||n<1)
            {
                    cout<<"非法,請重新輸入:";
                    cin>>n;
            }
            cout<<"n的階乘為:"<<fun(n)<<endl;
    }

    int fun(int n)
    {
            int i,result=1;

            for(i=1;i<=n;i++)
                    result*=i;
            return result;
    }

    3、從鍵盤上任意輸入一個長度不超過20的字符串,對所輸入的字符串,按照ASCII碼的大小從小到大進行排序,請輸出排序后的結果。
    #include<iostream>
    #include<string>

    using namespace std;

    void main()
    {
            char str[21];
            int i,j,len;
            char ch;

            cout<<"請輸入字符串:";
            cin.getline(str,20);
            len=strlen(str);
            for(i=0;i<len-1;i++)
                    for(j=0;j<len-1-i;j++)
                            if(str[j]>str[j+1])
                            {
                                    ch=str[j];
                                    str[j]=str[j+1];
                                    str[j+1]=ch;
                            }
            cout<<"排序后的字符串為:"<<str<<endl;
    }

    2002年A
    1、某人有8角的郵票5張,1元的郵票4張,1元8角的郵票6張,用這些郵票中的一張或若干張可以得到多少中不同的郵資?
    說明:這道題真的找不到好的算法,希望有好算法的朋友發站短給我,多謝
    #include<iostream.h>

    void main()
    {
            int i,j,k;

            for(i=0;i<=5;i++)
                    for(j=0;j<=4;j++)
                            for(k=0;k<=6;k++)
                                    cout<<i*0.8+j+k*1.8<<" ";
    }

    2、輸入n值,使用遞歸函數,求楊輝三角形中各個位置上的值,按照如下形式打印輸出圖形。例如:當n=6時。             1
    1 1
    1 2 1
    1 3 3 1
    1 4 6 4 1
    1 5 10 10 5 1
    說明:遞歸
    #include<iostream.h>

    int fun(int n,int k)
    {
            if(k==0||n==k)
                    return 1;
            else
                    return fun(n-1,k-1)+fun(n-1,k);
    }

    void main()
    {
            int n,i,j;

            cout<<"請輸入n:";
            cin>>n;
            for(i=0;i<n;i++)
            {
                    for(j=0;j<=i;j++)
                            cout<<fun(i,j)<<" ";
                    cout<<endl;
            }
    }

    2002年B
    1、打印所有不超過n(n<256)的,其平方具有對稱性質的數。如11*11=121。
    #include<iostream.h>
    #include<stdlib.h>

    bool fun(int n)
    {
            int x,i,t;
            char str[10];

            x=n*n;
            i=0;
            while(x)
            {
                    t=x%10;
                    str[i++]=t+48;
                    x/=10;
            }
            str='\0';
            if(n*n==atoi(str))
                    return true;
            else
                    return false;
    }

    void main()
    {
            int n,i;

            cout<<"請輸入n:";
            cin>>n;
            for(i=1;i<=n;i++)
                    if(fun(i))
                            cout<<i<<" ";
            cout<<endl;
    }

    2、編寫一個求菲波那奇數列的遞歸函數,輸入n值,使用該遞歸函數,輸出如下圖形。例如:當n=6時。        0
    0 1 1
    0 1 1 2 3
    0 1 1 2 3 5 8
    0 1 1 2 3 5 8 13 21
    0 1 1 2 3 5 8 13 21 34 55
    說明:遞歸
    #include<iostream.h>

    int fun(int n)
    {
            if(n==0)
                    return 0;
            else if(n==1)
                    return 1;
            else
                    return fun(n-2)+fun(n-1);
    }

    void main()
    {
            int n,i,j;
            int *p=new int[60];

            cout<<"請輸入n:";
            cin>>n;
            for(i=0;i<2*n-1;i++)
                    p[ i ]=fun(i);
            for(i=0;i<n;i++)
            {
                    for(j=0;j<2*i+1;j++)
                            cout<<p[j]<<" ";
                    cout<<endl;
            }
    }


    2003年
    1、輸入球的中心點和球上某一點的坐標,計算球的半徑和體積。
    #include<iostream.h>
    #include<math.h>

    void main()
    {
            double r;
            int x1,x2,y1,y2,z1,z2;
            const double PI=3.1416;
            
            cout<<"請輸入中心點坐標:";
            cin>>x1>>y1>>z1;
            cout<<"請輸入球上某一點的坐標:";
            cin>>x2>>y2>>z2;
            r=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)+(z1-z2)*(z1-z2));
            cout<<"半徑為:"<<r<<endl;
            cout<<"體積為:"<<(4*PI*r*r*r)/3<<endl;
    }

    2、手工建立一個文件,文件種每行包括學號、姓名、性別和年齡。每一個屬性使用空格分開。文件如下: 01 李江 男 21 02 劉唐 男 23 03 張軍 男 19 04 王娜 女 19 根據輸入的學號,查找文件,輸出學生的信息。
    #include<iostream>
    #include<fstream>
    #include<string>
    #include<stdlib.h>
    using namespace std;

    void main()
    {
            const int LEN=100;
            char s[LEN],k[LEN],*temp;
            int num;

            cout<<"請輸入要查找學生的學號:";
            cin>>num;
            ifstream fin("myfile.txt";
            
            while(fin.getline(s,LEN))
            {
                    strcpy(k,s);
                    temp=strtok(k," ");
                    if(atoi(temp)==num)
                    {
                            cout<<num<<"號學生的信息為:"<<s<<endl;
                            break;
                    }
            }
    }

    3、輸入年月日,計算該填是本年的第幾天。例如1990年9月20日是1990年的第263天,2000年5月1日是2000年第122天。(閏年:能被400正除,或能被4整除但不能被100整除。每年1、3、5、7、8、10為大月)
    #include<iostream.h>

    void main()
    {
            int i,sum=0,year,month,day;
            const int num[12]={31,28,31,30,31,30,31,31,30,31,30,31};

            cout<<"請輸入年月日:";
            cin>>year>>month>>day;
            for(i=0;i<month-1;i++)
                    sum+=num;
            sum+=day;
            if((year%4==0&&year%100!=0)||year%400==0)
                    sum+=1;
            cout<<year<<"年"<<month<<"月"<<day<<"日是"<<year<<"年的第"<<sum<<"天"<<endl;
    }


    2004年
    第一題是建立一個角類,在這個類中重載減號運算符,并實現求出角度的正弦值的函數。
    #include<iostream.h>
    #include<math.h>

    const double PI=3.1416;

    class angle
    {
    public:
            angle() {}
            angle(int x) {X=x;}
            angle operator - (angle c);
            void xsin();
    private:
            int X;
    };
    #include"angle.h"

    void angle::xsin()
    {

            double x;
            x=(X*PI)/180;
            cout<<"正弦值為:"<<sin(x)<<endl;
    }

    angle angle:perator - (angle c)
    {
            return angle(X-c.X);
    }
    #include"angle.h"

    void main()
    {
            angle c1(90),c2(60),c3;
            c3=c1-c2;
            c1.xsin();
            c2.xsin();
            c3.xsin();
    }

    第二題是建立一個求一元二次方程解的類(a*x^2+b*x+c=0),輸入系數a,b,c的值后打印出這個方程的解來,也比較簡單。需要注意的是系數a不能為零以及方程有無解,單解還是雙解的情況。
    #include<iostream.h>

    class equation
    {
    public:
            equation(float a,float b,float c):a(a),b(b),c(c) {}
            float D() {return b*b-4*a*c;}
            void fun();
    private:
            float a,b,c;
    };
    #include<math.h>
    #include"equation.h"

    void equation::fun()
    {
            float d=D();
            
            if(d==0)
                    cout<<"單解為:"<<-b/(2*a)<<endl;
            else if(d>0)
                    cout<<"雙解為:"<<(-b+sqrt(d))/(2*a)<<","<<(-b-sqrt(d))/(2*a)<<endl;
            else
                    cout<<"復數解為:"<<-b/(2*a)<<"+"<<sqrt(-d)/(2*a)<<"i,"<<-b/(2*a)<<"+"<<-sqrt(-d)/(2*a)<<"i"<<endl;
    }
    #include"equation.h"

    void main()
    {
            float a,b,c;

            cout<<"請輸入(a b c):";
            cin>>a>>b>>c;
            while(a==0)
            {
                    cout<<"非法,請重新輸入(a b c):";
                    cin>>a>>b>>c;
            }
            equation e(a,b,c);
            e.fun();
    }

    第三道題是實現一個多項式的類(a+b*x+c*x^2+d*x^3+...+),要求輸入該多項式的系數和x的值后打印出這個多項式的值。這道題本身并不難,但他要求用好的算法(實際上就是遞歸)。
    #include<iostream.h>

    float fun(float s[],float x,int n,int N)
    {
            if(n==0)
                    return s[N];
            else
                    return s[N-n]+x*fun(s,x,n-1,N);
    }

    void main()
    {
            int i,N;
            float num[60],x;

            cout<<"請輸入最高項次數:";
            cin>>N;
            cout<<"請依次輸入系數:";
            for(i=0;i<=N;i++)
                    cin>>num[ i ];
            cout<<"請輸入x:";
            cin>>x;
            cout<<"結果為:"<<fun(num,x,N,N)<<endl;
    }

    2005年
    第一題是給定一個程序,關于字符串的,要求輸入并調試,說出此程序的意圖。意圖是按字母順序對兩個字符串比較排序。第二問要求用盡可能少的語句對該程序進行修改,使其能夠對兩個字符串比較長度排序。本題滿分20。

    第二題是要求編寫一個日期類,要求按xxxx-xx-xx的格式輸出日期,實現加一天的操作,不考慮閏年問題,所有月份設為30天。本題黑盒測試時,輸入2004年3月20日,得到加一天后時間為2004-3-21,能得一部分分數。輸入2004年3月30日,得到加一天后時間為2004-4-1,能得一部分分數。輸入2004年12月30日,得到加一天后時間為2005-1-1,且有時間越界處理,能得全部分數。本題滿分30。
    #include<iostream.h>

    class date
    {
    public:
            date(int y,int m,int d):year(y),month(m),day(d){}
            void display();
            void addDay();
    private:
            int year;
            int month;
            int day;
    };
    #include"date.h"

    void date::display()
    {
            cout<<year<<"-"<<month<<"-"<<day<<endl;
    }

    void date::addDay()
    {
            day++;
            if(day>30)
            {
                    day%=30;
                    month++;
                    if(month>12)
                    {
                            month%=12;
                            year++;
                    }
            }
    }
    #include"date.h"

    void main()
    {
            int y,m,d;

            cout<<"請輸入(年 月 日):";
            cin>>y>>m>>d;
            while(y<0||m<0||m>12||d<0||d>30)
            {
                    cout<<"非法,請重新輸入(年 月 日):";
                    cin>>y>>m>>d;
            }
            date d1(y,m,d);
            d1.addDay();
            d1.display();
    }

    第三題要求編寫一個復數類,要求有4條。一是有構造函數,能對復數初始化。二是對復數c1,c2,c3.....能實現連加運算,令c=c1+c2+c3+.....此處可以重載加法操作符。三是有函數實現兩個復數相加,并按照a+ib的形式輸出。四是能實現對一個復數c=a+ib,定義double x=c有效,使x的值為實部和虛部之和。本題滿分50。”
    #include<iostream>
    using namespace std;
    class complex
    {
    public:
            complex(double r=0.0,double i=0.0) {real=r;imag=i;}
            complex operator + (complex c2);
            void display();
            operator double ()                //重載類型轉換操作
            {
                    return  (real+imag);
            }
    private:
            double real;
            double imag;
    };
    #include"complex.h"

    complex complex:perator + (complex c2)
    {
            return complex(real+c2.real,imag+c2.imag);
    }

    void complex::display()
    {
            cout<<real<<"+"<<imag<<"i"<<endl;
    }
    #include"complex.h"

    void main()
    {
            complex c1(5,4),c2(2,10),c3(6,9),c4;

            c4=c1+c2+c3;
            c4.display();
            double x=c4;
            cout<<x<<endl;
    }


    2006年
    1.寫一個程序判斷字符串中數字的位置(不限制使用面向對象編程)
    例如: 輸入   a3b4c5
         輸出   2 4 6
    #include<iostream>
    #include<ctype.h>
    #include<string>
    using namespace std;

    void main()
    {
            string str;
            int i;

            cout<<"請輸入字符串:";
            getline(cin,str);
            for(i=0;str[ i ]!='\0';i++)
                    if(isdigit(str[ i ]))
                            cout<<i+1<<" ";
            cout<<endl;
    }

    2.寫一個類,能接受int型的變量,接收變量后能存儲原變量(譬如12345)和其反向變量(54321),最多處理數量為10個,當輸入達到10個或者輸入變量為0的時候停止。并且在類銷毀前輸出存儲的所有變量。
    例如: 輸入:12345,2234,0
                輸出:12345   54321
                        2234  4322
    #include<iostream.h>
    #include<stdlib.h>

    class CInverse
    {
    public:
            CInverse();
            void inverse();
            ~CInverse();
    private:
            int num[10];
            int inverseNum[10];
            int countNum;
    };
    #include"CInverse.h"

    CInverse::CInverse()
    {
            int t,i;

            cout<<"請輸入整數,以0停止:";
            cin>>t;
            for(i=0;i<10&&t!=0;i++)
            {
                    num[ i ]=t;
                    cin>>t;
            }
            countNum=i;
    }

    void CInverse::inverse()
    {
            char str[10];
            int t,i,j,x;
            
            for(i=0;i<countNum;i++)
            {
                    x=num;
                    j=0;
                    while(x)
                    {
                            t=x%10;
                            str[j++]=t+48;                //加48
                            x/=10;
                    }
                    str[j]='\0';
                    inverseNum=atoi(str);
            }
    }

    CInverse::~CInverse()
    {
            int i;

            for(i=0;i<countNum;i++)
                    cout<<num<<" "<<inverseNum<<endl;
    }
    #include"CInverse.h"

    void main()
    {
            CInverse c1;
            c1.inverse();
    }

    3.寫一個CTriangle類,要求可以接受 CTriangle(y,x)形式的構造,創建在坐標系中的直角三角形樣子如下
    三點的坐標分別是A(0,y) B(0,0) C(x,0)
    實現+運算,并且能夠處理鍵盤連續輸入若干個(少于十個)三角形,并且連加(相加時候三角形邊長長度相加,方向同第一個三角形)。輸入0后結束并輸出最后得出的三角形的三個坐標值。
    #include<iostream.h>

    class CTriangle
    {
    public:
            CTriangle(int y=0,int x=0) {Ay=y;Cx=x;}
            CTriangle operator + (CTriangle c2);
            void set(int y=0,int x=0) {Ay=y;Cx=x;}
            void display();
    private:
            int Ay;
            int Cx;
    };
    #include"CTriangle.h"

    CTriangle CTriangle:perator + (CTriangle c2)
    {
            return CTriangle(Ay+c2.Ay,Cx+c2.Cx);
    }

    void CTriangle::display()
    {
            cout<<"A(0,"<<Ay<<") B(0,0) C("<<Cx<<",0)"<<endl;
    }
    #include"CTriangle.h"

    void main()
    {
            int y,x,i,N;
            CTriangle c[10],sum;

            cout<<"請輸入坐標:";
            cin>>y;
            for(i=0;y!=0;i++)
            {
                    cin>>x;
                    c[ i ].set(y,x);
                    cin>>y;
            }
            N=i;
            sum.set();                //置0
            for(i=0;i<N;i++)
                    sum=sum+c;
            sum.display();
    }


    2007年
    1。一個小球,從高為H的地方下落,下落彈地之后彈起高度為下落時的一半,
    比如第一次彈起高度為H/2,如此往復,計算從小球H高度下落到第n次彈地
    往返的總路程。
    要求:1。用遞歸的方法實現
          2。輸入H和n,輸出結果
          3。注意程序的健壯性
          4。可以用C或C++實現
    #include<iostream.h>
    #include<math.h>

    float fun(int n)
    {
            if(n==1)
                    return 1;
            else
                    return fun(n-1)+1/pow(2,n-2);
    }

    void main()
    {
            float H;
            int n;

            cout<<"請輸入H和n:";
            cin>>H>>n;
            cout<<"小球從"<<H<<"高度下落到第"<<n<<"次彈地往返的總路程為:"<<fun(n)*H<<endl;
    }

    2。創建一個CPoint類,代表平面直角坐標系中的點,創建構造函數和運算符重載函數,
    運算符重載為類重載(非友元重載),可以實現計算兩個點之間的距離。可以根據需要
    加入自己的成員變量或成員函數
    要求:1。輸入兩個點的坐標,輸出兩個點之間的距離
          2。重載運算符為“-”
    #include<iostream.h>

    class CPoint
    {
    public:
            CPoint(int x=0,int y=0) {X=x;Y=y;}
            float operator - (CPoint c2);
    private:
            int X;
            int Y;
    };
    #include"CPoint.h"
    #include<math.h>

    float CPoint:perator - (CPoint c2)
    {
            return sqrt((X-c2.X)*(X-c2.X)+(Y-c2.Y)*(Y-c2.Y));
    }
    #include "CPoint.h"

    void main()
    {
            int x1,y1,x2,y2;

            cout<<"請輸入兩個點的坐標:";
            cin>>x1>>y1>>x2>>y2;
            CPoint c1(x1,y1),c2(x2,y2);
            cout<<"兩點間的距離為:"<<c1-c2<<endl;
    }

    3。創建一個CTriangle類,需要用到第二題中創建的類,即用3點來代表一個三角形,
    輸入三個點的坐標,實現判斷此三角形是不是直角三角形,并輸出此三角形的周長。
    可以根據需要加入自己的成員變量或成員函數
    要求:1。輸入三個點的坐標,輸出周長并給出是否直角三角形的信息
          2。注意程序的健壯性
    #include<iostream.h>

    class CPoint
    {
    public:
            CPoint(int x=0,int y=0) {X=x;Y=y;}
            float operator - (CPoint c2);
    private:
            int X;
            int Y;
    };

    class CTriangle
    {
    public:
            CTriangle(CPoint a,CPoint b,CPoint c):A(a),B(b),C(c)
            {
                    AB=A-B;
                    BC=B-C;
                    AC=A-C;
            }
            void display();
            bool fun();
    private:
            CPoint A,B,C;
            float AB,BC,AC;
    };
    #include"CTriangle.h"
    #include<math.h>

    float CPoint:perator - (CPoint c2)
    {
            return (float)sqrt((X-c2.X)*(X-c2.X)+(Y-c2.Y)*(Y-c2.Y));
    }

    void CTriangle::display()
    {
            cout<<"周長為:"<<AB+BC+AC<<endl;
    }

    bool CTriangle::fun()
    {
            float a=AB,b=BC,c=AC,t;

            if(a>c)
            {
                    t=a;
                    a=c;
                    c=t;
            }
            if(b>c)
            {
                    t=b;
                    b=c;
                    c=t;
            }
            if(fabs(a*a+b*b-c*c)<10e-6)
                    return true;
            else
                    return false;
    }
    #include"CTriangle.h"

    void main()
    {
            int x1,y1,x2,y2,x3,y3;

            cout<<"請輸入三個頂點的坐標:";
            cin>>x1>>y1>>x2>>y2>>x3>>y3;
            CPoint p1(x1,y1),p2(x2,y2),p3(x3,y3);
            CTriangle c(p1,p2,p3);
            if(c.fun())
            {
                    cout<<"是直角三角形"<<endl;
                    c.display();
            }
            else
                    cout<<"不是直角三角形"<<endl;
    }


    2008年
    1、存儲一組姓名,如 Apple,Tom,Green,Jack 要求能排序、按字母順序插入、并顯示。
    #include<iostream>
    #include<string>
    using namespace std;

    void main()
    {
            const int N=10;
            string s[N],temp;
            int i,j,K;

            cout<<"請輸入字符串個數:";
            cin>>K;
            cout<<"請輸入"<<K<<"個字符串:"<<endl;
            for(i=0;i<K;i++)                //插入排序
            {
                    cin>>temp;
                    for(j=i;j>0;j--)
                            if(temp<s[j-1])
                                    s[j]=s[j-1];
                            else
                                    break;
                    s[j]=temp;
            }
            cout<<"排序后的結果為:"<<endl;
            for(i=0;i<K;i++)
                    cout<<s<<endl;
    }       
    zz

    回復話題
    上傳/修改頭像

    100除以5等于多少?

    考研論壇提示:
    1、請勿發布個人聯系方式或詢問他人聯系方式,包括QQ和手機等。
    2、未經允許不得發布任何資料出售、招生中介等廣告信息。
    3、如果發布了涉及以上內容的話題或跟帖,您在考研網的注冊賬戶可能被禁用。

    網站介紹 | 關于我們 | 聯系方式 | 廣告業務 | 幫助信息
    ©1998-2015 ChinaKaoyan.com Network Studio. All Rights Reserved.

    中國考研網-聯系地址:上海市郵政信箱088-014號 郵編:200092 Tel & Fax:021 - 5589 1949 滬ICP備12018245號

    最近中文字幕大全中文字幕免费| 久久久久久久人妻无码中文字幕爆 | 亚洲AV日韩AV永久无码久久| AAA级久久久精品无码区| 中文无码伦av中文字幕| 亚洲va无码专区国产乱码| 中文字幕无码日韩专区| 亚洲av无码潮喷在线观看| 日本精品久久久久中文字幕| HEYZO无码综合国产精品| 中文字幕亚洲综合久久菠萝蜜| 久久精品无码午夜福利理论片| 天堂а√在线地址中文在线| 久久亚洲精品无码观看不卡| 中文字幕在线无码一区| 中文字幕无码一区二区三区本日| 无码人妻一区二区三区兔费| 人妻无码中文久久久久专区| 成人无码一区二区三区| 久久午夜福利无码1000合集| 少妇中文字幕乱码亚洲影视| 免费在线中文日本| 高清无码视频直接看| 丰满日韩放荡少妇无码视频| 中文亚洲AV片在线观看不卡| 国产V亚洲V天堂无码久久久| 成人无码免费一区二区三区| 好看的中文字幕二区高清在线观看| 国产精品无码一区二区在线观一 | 亚洲国产a∨无码中文777| 在线看无码的免费网站| 性无码免费一区二区三区在线| 中文字幕成人免费视频| 最好看的2018中文在线观看 | 亚洲中文字幕第一页在线| 911国产免费无码专区| 亚洲AV综合色区无码一区爱AV| 国内精品久久久久久中文字幕| 中文字幕在线亚洲精品| 久久亚洲中文字幕精品一区四| 熟妇人妻不卡中文字幕|