[Codeforces] 208A – Dubstep [c]

Problem Link: 208A – Dubstep

 
[c]
#include<stdio.h>
int main()
{
char a[200],b[200];
gets(a);
int i,j=0,k=0;
int len=strlen(a);
for(i=0;i<len;i++){
if(a[i]==’W’ && a[i+1]==’U’ && a[i+2]==’B’){
i+=2;
k=1;
}
else{
if(k==1 && j>0){
b[j]=’ ‘;
j++;
}
b[j]=a[i];
k=2;
j++;
}
}
b[j]=’\0’;
puts(b);
return 0;
}

[/c]

[Codeforces] 339A – Helpful Maths [c]

Problem link: 339A – Helpful Maths

 
http://codeforces.com/problemset/problem/339/A
 
[c]
#include<stdio.h>

int main()
{
char b[100],c[100];
int i,j;
gets(b);
j=0;
for(i=0;b[i]!=’\0’;i++){
if(b[i]==’1′ || b[i]==’2′ || b[i]==’3′){
c[j]=b[i];
j++;
}
}
c[j]=’\0’;
int d=j-1;
int k,l;
char temp;
for(k=0;k<j-1;k++){
for(l=0;l<j-1-k;l++){
if(c[l]>c[l+1]){
temp=c[l+1];
c[l+1]=c[l];
c[l]=temp;
}
}
}
for(j=0;j<=d;j++){
if(j>0)
printf("+");
printf("%c",c[j]);
}
return 0;
}

[/c]