Created
July 13, 2013 06:16
-
-
Save Shravan40/5989627 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
using namespace std; | |
int main() | |
{ | |
int t,n,i,m; | |
cin>>t; | |
while(t--) | |
{ | |
cin>>n; | |
m = n; | |
int size = 0 , i = 0, temp = 0, prod; | |
int arr [200]; | |
while(n != 0) | |
{ | |
temp = n % 10; | |
arr[i] = temp; | |
n /= 10; | |
size++, i++; | |
} | |
temp = 0; | |
m -= 1; | |
while(m > 0) | |
{ | |
for(i = 0; i < size; i++) | |
{ | |
prod = arr[i] * m + temp; | |
arr[i] = prod % 10; | |
temp = prod / 10; | |
} | |
while(temp != 0) | |
{ | |
arr[i] = temp % 10; | |
temp /= 10; | |
size++, i++; | |
} | |
m--; | |
} | |
for (i = size-1; i >= 0; i--) | |
{ | |
cout<<arr[i]; | |
} | |
cout<<endl; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment