put the difigits in an array then sort the array.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
To make the program better, put the 'work' in a loop. That way you only need one % and /. When the number is 0 the loop is finished.
WaltP
Posting Sage w/ dash of thyme
10,506 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
Suggestion is to use std::string and std::sort. Its just a few liner :
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
std::string input;
cin >> input; //get input
std::sort(input.begin(),input.end()); //sort it
cout << input << endl; //print it
//or access each element like so
/*
for(int i = 0; i < input.size(); ++i){
cout << str[i] << " ";
}
*/
}
firstPerson
Senior Poster
3,923 posts since Dec 2008
Reputation Points: 841
Solved Threads: 608