- 0
Notifications Mark All Read
No New notification
- Login
- Get Prime
Problem 52
Access Denied!
To view this page you have to login first
Login here -
Trivia
Did you know 1 million people use PrepInsta everyday?
Notifications Mark All Read
No New notification
To view this page you have to login first
Login here -
Did you know 1 million people use PrepInsta everyday?
#Python
l=list(map(str,input().split(” “)))
l1=[]
for i in range(len(l)):
l1.append(eval(l[i]))
l1.sort()
for i in range(len(l1)):
print(str(l1[i]))
n=str(input(‘enter the numeric string : ‘))
c=[]
for i in n:
y=int(i)
c.append(y)
print(c)
c.sort()
for i in c:
print(i)
By..Gunjan soni
#python3
def sorting(ar):
for j in sorted([int(i) for i in ar]):
print(j,end=’ ‘)
n=int(input(‘enter the length of the array:\t’))
li=[]
for i in range(n):
inp=str(input(‘enter the numeric string:\t’))
li.append(inp)
sorting(li)
#include
#include
int main()
{
char a[100];
gets(a);
int l,i,k=0,na[100],j,t;
for(l=0;a[l];l++);
for(i=0;i<l;i++)
{
if(a[i]=='0' || a[i]=='1' ||a[i]=='2' ||a[i]=='3' ||a[i]=='4' ||a[i]=='5' ||a[i]=='6' ||a[i]=='7' ||a[i]=='8' ||a[i]=='9')
{
a[i]=a[i]-48;
na[k]=a[i];
k++;
}
}
for(i=0;i<k;i++)
{
for(j=i+1;jna[j])
{
t=na[i];
na[i]=na[j];
na[j]=t;
}
}
}
for(i=0;i<k;i++)
printf("%d ",na[i]);
}
input:-prep5420insta19
output:-0 1 2 4 5 9
#include
int main()
{
char inputStr[100];
int i,k=0,num[100],t=0,sum=0;
printf(“Enter your string : “);
scanf(“%[^\n]%c”,inputStr);
int j = 0;
for(i=0; inputStr[i] ;i++)
{
//5
if(inputStr[i] >= ‘0’ && inputStr[i] <= '9')
{
num[k++]=inputStr[i]-48;
}
}
for(i=0;i<k;i++)
{
for(j=i+1;jnum[j])
{
t=num[i];
num[i]=num[j];
num[j]=t;
}
}
}
for(i=0;i<k;i++)
{
printf("%d",num[i]);
}
for(i=0;i<k;i++)
{
sum+=num[i];
}
printf("\n%d",sum);
}
//Additionally added the suming of digits as well