-
Notifications
You must be signed in to change notification settings - Fork 0
/
B.c
42 lines (42 loc) · 768 Bytes
/
B.c
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
#include<stdio.h>
int main()
{
int t,n,zero,one,i;
char s[100005];
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
scanf("%s",&s);
zero=0;
one=0;
for(i=0;i<n;i++)
{
if(s[i]=='1')
break;
else
zero++;
}
for(i=n-1;i>=0;i--)
{
if(s[i]=='0')
break;
else
one++;
}
if(zero+one==n)
{
printf("%s",s);
printf("\n");
}
else
{
for(i=0;i<=zero;i++)
printf("0");
for(i=0;i<one;i++)
printf("1");
printf("\n");
}
}
return 0;
}