Results 1 to 3 of 3

Thread: , ++

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User BeTaTesTeR's Avatar
    Join Date: Nov:2006
    Location:
    Posts: 6,693

    , ++

    , ++ . - . :
    . . ++ :
    - N ,
    -
    -
    . .
    :
    Code:
    #include <iostream.h>
    #include <stdio.h>
    #include <math.h>
    class dot {
    double x;
    double y;
    public:
    	void input(void);
    	void output(void);
    };
    
    void dot::input(void)
    { 	
    	cout<<endl;
    	cout<<"Input X=";
    	cin>>x;
    	cout<<"Input Y=";
    	cin>>y;
    	return;
    }
    
    void dot::output()
    {	
    	cout<<endl;
    	cout<<"X="<<x<<endl;
    	cout<<"Y="<<y<<endl;
    	return;
    }
    
    dot *dots;
    
    void bubblesort(int *m, int size)
    {
        for(int i=size; i>0; i--)
            for(int j=0; j<i-1; j++)
                if(m[j] > m[j+1])
                {
                    int t = m[j];
                    m[j] = m[j+1];
                    m[j+1] = t;
                }
    }
    
    
    int main()
    {
    	int n;
    	cout<<"Kolko to4ki 6te vuvejdate:";
    cin>>n;
      dots= new dot[n];
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
        for(int i=0;i<n;i++)
      {		
    	  cout<<"Input dot "<<i+1<<" :";
    	  dots[i].input();
    	  
    	  
    }
      cout<<"Vuvedenite tochki sa:"<<endl;
      for(int j=0;j<n;j++) {
    	  
    	  cout<<"Dot"<<j+1<<" : ";
    	  dots[j].output();
      }
    
    bubblesort (dots,n);
    for(int k=0; k<n; k++) {
    	cout<<dots[k]<<endl;
    
    }
    
    
    	
    	return 0;
    }
    , . , bubblesort . . , bubblesort , , . main bubblesort .
    !

  2. #2
    Registered User
    Join Date: Jan:2005
    Location: BG
    Posts: 4,903
    ?
    , , ... ...

  3. #3
    Eek's Avatar
    Join Date: Aug:2005
    Location:
    Posts: 2,808
    , int, dot, . get , :

    Code:
    void bubblesort(dot *m, int size)
    {   dot *t = new dot;
        for(int i=size; i>0; i--)
            for(int j=0; j<i-1; j++)
                if(m[j].gety() > m[j+1].gety())
                {
                    t=m[j];
                    m[j] = m[j+1];
                    m[j+1] = t;
                }
     delete t;
    }

    delete[] dots;
    Last edited by Eek; 15th April 2011 at 19:16.
    Geniess die Ruhe

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 |