View Code of Problem 54

#include <bits/stdc++.h>
using namespace std;

int main()
{
	int n;
	while(cin>>n) {
		int len = 0;
		int a[100];
		int x = n;
		do{
			a[len++] = x%10;
			x /= 10;
		}while(x>0);
		for(int i=len-1;i>=0;i--) {
			cout<<a[i];
			if(i!=0)
				cout<<" ";
			else 
				cout<<endl;
		}
	}
	
	
	return 0;
}

Double click to view unformatted code.


Back to problem 54