#include <stdio.h>
#include <string.h>
int main ()
{
char s[1000];
int i, j = 0, k, l, ln, arr[1000], m, n, temp;
scanf("%s", s);
ln = strlen(s);
for(i = 0; i < ln; i++)
{
if((i % 2) == 0)
{
arr[j] = (int) s[i];
j++;
}
}
for(m = 1; m < j; m++)
{
for(n = 0; n < (j - m); n++)
{
if(arr[n] > arr[n + 1])
{
temp = arr[n];
arr[n] = arr[n + 1];
arr[n + 1] = temp;
}
}
}
for(k = 0; k < j; k++)
{
if(k == (j - 1))
{
printf("%c", (char) arr[k]);
}
else
{
printf("%c%c", (char) arr[k], '+');
}
}
printf("\n");
return 0;
}
#include
ReplyDelete#include
int main ()
{
char s[1000];
int i, j,p;
gets(s);
for(i=0; s[i+1]!='\0'; i++)
for(j=i; s[j]!='\0'; j++)
if(s[i]!='+' && s[j]!='+')
if(s[j]<s[i])
{
p=s[j];
s[j]=s[i];
s[i]=p;
}
printf("%s\n", s);
return 0;
}
This comment has been removed by the author.
ReplyDelete#include
ReplyDelete#include
int main()
{
char s[101];
int n,i,j;
scanf("%s",&s);
n=strlen(s);
for( i=0; is[i])
{
char tmp=s[i];
s[i]=s[j];
s[j]=tmp;
}
}
}
printf("%s",s);
return 0;
}