/*
Write a program that read a any integer number from the user, forming the
greatest possible number with the digits in it. (E.g 395 forms 953)
*/
#include
#include
#include
using namespace std;
int main()
{
int i,j,num=0;
unsigned int count=-1;
multiset myset;
multiset::reverse_iterator it;
cout << "enter any no: ";
cin >> i;
while(i>0) {
j = i % 10;
i = i/10;
myset.insert(j);
++count;
}
cout << "count= "<< count << endl;
cout << "myset contains:";
for (it=myset.rbegin();it!=myset.rend();it++) {
cout << " " << *it;
num = num + (*it) * ceil(pow(10,count));
--count;
}
cout << endl << "num = " << num << endl;
}
Write a program that read a any integer number from the user, forming the
greatest possible number with the digits in it. (E.g 395 forms 953)
*/
#include
#include
#include
using namespace std;
int main()
{
int i,j,num=0;
unsigned int count=-1;
multiset
multiset
cout << "enter any no: ";
cin >> i;
while(i>0) {
j = i % 10;
i = i/10;
myset.insert(j);
++count;
}
cout << "count= "<< count << endl;
cout << "myset contains:";
for (it=myset.rbegin();it!=myset.rend();it++) {
cout << " " << *it;
num = num + (*it) * ceil(pow(10,count));
--count;
}
cout << endl << "num = " << num << endl;
}
No comments:
Post a Comment