1 solutions
-
0
C++ :
#include <bits/stdc++.h> using namespace std; bool compare(int a,int b){ return a > b; } int main(){ int r[4010],i,n,k = 0,x; cin>>n; for(i = 0;i < n;i++){ cin>>x; while(x != 0){ r[k] = x % 10; x = x / 10; k++; } } sort(r,r+k,compare); for(i = 0;i < k;i++){ cout<<r[i]; } }
Python :
n=int(input()) a=input().split() a=list(map(int,a)) b=[] for i in a: k=len(str(i)) for j in range(k): m=int(str(i)[j:j+1]) b.append(m) b=sorted(b) b.reverse() s=0 for i in range(0,len(b)): s=s*10+b[i] print(s)
- 1
Information
- ID
- 10454
- Time
- 1000ms
- Memory
- 32MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By