View Code of Problem 54

#include <iostream>
using namespace std;

int main(){
  long int n;
  cin>>n;
  int a[100],x=0;
  while(n){
    a[x] = n%10;
    n/=10;
    x++;
  }
  
  for(int j=x-1;j>=0;j--){
    if(j==x-1)
      printf("%d",a[j]);
    else
      printf(" %d",a[j]);
  }
  return 0;
}

Double click to view unformatted code.


Back to problem 54