Results 1 to 6 of 6

Thread: ++

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date: Dec:2008
    Location: Bulgaria
    Posts: 1

    ++

    !
    , . : ,: , , . .


    #include<iostream.h>
    #include<math.h>

    class line {

    private:
    double x1,y1;
    double x2,y2;

    public:
    void input();
    void output();
    //double length_a();
    };

    void line::input() {
    ...........................
    ...........................
    ...........................

    class triangle {

    private:
    double x1,y1;
    double x2,y2;
    double x3,y3;

    public:
    void Input();
    void Output();
    double lenght_a();
    double lenght_b();
    double lenght_c();
    // double p();
    // double S();
    };


    .

  2. #2
    Registered User vegasis's Avatar
    Join Date: Jun:2005
    Location:
    Posts: 1,156
    .
    :

    class Point
    {
    public:
    double x;
    double y;


    public:
    Point();
    Point(const Point&); //
    Point(const double x, const double y);
    void set(const double x, const double y);


    bool operator==(const Point&) const;
    bool operator!=(const Point&) const;
    Point operator+(const Point&) const;
    Point operator-(const Point&) const;
    Point& operator+=(const Point&);
    Point& operator-=(const Point&);
    Point operator*(const double) const;
    Point& operator*=(const double);
    Point operator/(const double) const;
    Point& operator/=(const double);
    Point operator-() const;
    };

    .

  3. #3
    Registered User
    Join Date: Jan:2009
    Location: Madan
    Posts: 1
    !
    !
    , . ?
    . , . !
    :
    #include<iostream.h>
    #include<string.h>
    struct books
    {
    int sign, br_ekz;
    char first[20],second[30],third[30],title[100];
    double price;
    } b;
    void vhod(books b[], int &n)
    {
    cout<<"Signaturen nomer na kniga: ";
    cin>>b[i].sign;
    cout<<"Zaglavie na kniga: ";
    cin>>b[i].title;
    cout<<"Sobstveno ime na avtora: ";
    cin>>b[i].first;
    cout<<"Prezime na avtora: ";
    cin>>b[i].second;
    cout<<"Familiq na avtora: ";
    cin>>b[i].third;
    do
    {
    cout<<"Broi ekzemplri na kniga: ";
    cin>>b[i].br_ekz;
    }
    while ( (b[i].br_ekz<1) || (b[i].br_ekz>51) );
    }
    do
    {
    cout<<"Edinichna cena:";
    cin>>b[i].price;
    }
    while( (b[i].price<1) || (b[i].price>100) );
    }
    void sign(books b[],int n)
    {
    books swap;
    double sum[1000],swap2; //sum
    for(int i=0;i<n-1;i++)
    {
    sum[i]=b[i].price*b[i].br_ekz;
    for(int j=0;j<n-i-1;j++)
    if(b[j].sign>b[j+1].sign)
    {
    swap=b[j];
    swap2=sum[j];
    b[j]=b[j+1];
    sum[j]=sum[j+1];
    b[j+1]=swap;
    sum[j+1]=swap2;
    }
    }

    for(int k=0;k<n;k++)
    cout<<b[k].sign<<" ";
    cout<<b[k].title<<" ";
    cout<<b[k].third<<" ";
    cout<<b[k].second<<" ";
    cout<<b[k].first<<" ";
    cout<<b[k].price<<" ";
    cout<<b[k].br_ekz<<" ";
    cout<<sum[k]<<endl;
    }
    void sortniz(books b[],int n)
    {
    double sum[1000];
    books swap;
    for(int i=0;i<n-1;i++)
    for(int j=0;j<n-i-1;j++)
    if(sum[j-1]>sum[j])
    {
    swap=b[j];
    b[j]=b[j-1];
    b[j-1]=b[j];
    }
    else
    if(sum[j-1]==sum[j])
    if(b[j].sign>b[j-1].sign)
    {
    swap=b[j];
    b[j]=b[j-1];
    b[j-1]=swap;
    }
    for(int k=0;k<n;k++)
    cout<<b[k].sign<<" ";
    cout<<b[k].title<<" ";
    cout<<b[k].first[0]<<" ";
    cout<<b[k].second[0]<<" ";
    cout<<b[k].third<<" ";
    cout<<b[k].price<<" ";
    cout<<b[k].br_ekz<<" ";
    cout<<sum[k]<<endl;
    }
    void middle(books b[],int n)
    {
    double sum=0,sr=1;
    int br=0;
    for(int i=0;i<n;i++)
    {
    sum+=b[i].price; br++;
    }
    sr=sum/br;
    cout<<endl;
    cout<<"Srednata aritmetichna cena e: "<<sr;
    }
    void author(books b[],int n)
    {
    double sr;
    for(int i=0;i<n;i++)
    if(b[i].price>sr && b[i].br_ekz>3)
    cout<<endl;
    cout<<b[i].first[0]<<endl;
    cout<<b[i].second[0]<<".";
    cout<<b[i].third<<".";
    }
    void main()
    {
    books b[100];
    int n;
    {
    do
    {
    cout<<endl;
    cout<<"Broi knigi: ";
    cin>>n;
    }
    while( (n<4) || (n>5001) );
    for(int i=0;i<n;i++)

    vhod(b,n);
    sign(b,n);
    sortniz(b,n);
    middle(b,n);
    author(b,n);
    }
    }

  4. #4
    Registered User Mechkov's Avatar
    Join Date: Jan:2009
    Location: internet
    Posts: 531
    Quote Originally Posted by Miss_Devilche View Post
    !
    !
    , . ?
    . , . !
    ...
    . - - -. - , - . . / / . . , O(n^2). n n . - , . include- STL- algorithm stdlib.h sort/qsort.

  5. #5
    Registered User
    Join Date: Dec:2007
    Location: Sofia
    Posts: 366
    , . sortniz() .

  6. #6
    Banned
    Join Date: Oct:2001
    Location: , -5
    Posts: 2,637
    C++ . , . , Wikipedia, . , -, , . , , .

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Copyright © 1999-2011 . .
iskamPC.com | mobility.BG | Bloody's Techblog | | 3D Vision Blog |