#include <cstdlib>
#include <iostream>
usingnamespace std;
void order(int* s1,int* s2)
{
if(*s1 > *s2)
{
int temp;
temp = *s1;
*s1 = *s2;
*s2 = temp;
}
}
/////////////////////////////77777777
class myclass
{
private:
int* ptr;
int len;
public:
myclass(int n): len(n)
{
ptr = newint[len];
}
void get_data()
{
for(int i = 0; i < len; i++)
{
cout << "Enter data: ";
cin >> *(ptr+i) ;
}
}
void put_data()
{
for(int i = 0; i < len; i++)
cout<<*(ptr+i)<<endl;
}
int most_bignumber()
{
int big=0;
for(int i = 0; i < len-1; i++){
for(int k = i+1; i < len; k++){
order(ptr+i,ptr+k);
}
}
big=*ptr+len;
return big;
}
//deleting
~myclass()
{
delete[] ptr;
cout << " bye bye " << endl;
}
};
int main(int argc, char *argv[])
{
int big=0;
myclass n1(4);
n1.get_data();
n1.put_data();
big = n1.most_bignumber();
cout << big << endl;
system("PAUSE");
return EXIT_SUCCESS;
}
i want to sort data and i writing most big number.but i can't it.problem is order function or most_bignumber().but i don't see.it's working but I take runtime error.I maybe use (**) syntax but it's doesnt necessary.I'am sure. what do you think about this and help me please ?
thank u.but line 34 or 41 working.also i delete most_bignumber() it's working.so there aren't problem.maybe line 54:S. my problem is order or most_bignumber() but i dont solve it
Yes, I agree. Your problem is on line 54. I suggested that you compare line 54 to lines 34 and 41. 34 and 41 work right; 54 doesn't. What are you doing differently?