-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path58940464.cpp
More file actions
54 lines (54 loc) · 959 Bytes
/
58940464.cpp
File metadata and controls
54 lines (54 loc) · 959 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <bits/stdc++.h>
using namespace std;
bool isnotempty(int arr[],int n);
int main()
{
int n;
cin>>n;
int result=0;
int m=n;
int arr[7];
fill(arr,arr+7,0);
int i=0;
while(m)
{
result=max(result,m%10);
arr[i]=m%10;
i++;
m/=10;
}
cout<<result<<endl;
while(isnotempty(arr,7))
{
//find first 1
int first=-1;
for(int i=6;i>=0;i--)
{
if(arr[i]!=0)
{
first=i;
break;
}
}
for(int i=first;i>=0;i--)
{
if(arr[i]!=0)
{
arr[i]--;
printf("1");
}
else
{
printf("0");
}
}
printf(" ");
}
return 0;
}
bool isnotempty(int arr[],int n)
{
for(int i=0;i<n;i++)
if(arr[i]!=0) return true;
return false;
}