Results 1 to 3 of 3
Thread: , ++
Hybrid View
-
12th April 2011 20:24 #1
, ++
, ++
. - . :
. . ++ :
- N ,
-
-
. .
:
, . , bubblesort . . ,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 , , . main bubblesort .
!
-
14th April 2011 12:41 #2Registered User
Join Date: Jan:2005
Location: BG
Posts: 4,903
?
, , ... ...
-
14th April 2011 14:36 #3
, 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




Reply With Quote
Lenovo ThinkPad 15 IdeaPad 15
5th May 2023, 22:16 in