#include<stdio.h>
#include<stdlib.h>
#include<string.h>
char *getS(char *arr,int n)
{
int i=0,b=0;
while(arr[i]!='\0')
{
if(arr[i]==' ')
b++;
i++;
}
int newlen=i+1+b*2;
if(newlen>n)
return NULL;
int j=newlen-1,z=i;
while(z>=0)
{
while(arr[z]!=' ' && z>=0)
{
arr[j]=arr[z];
j--;
z--;
}
if(z<0)
{
break;
}
arr[j]='0';
arr[j-1]='2';
arr[j-2]='%';
j=j-3;
z=z-1;
}
return arr;
}
void main()
{
char s[100]="we are happy.";
printf("%s",getS(s,100));
}
#include<stdlib.h>
#include<string.h>
char *getS(char *arr,int n)
{
int i=0,b=0;
while(arr[i]!='\0')
{
if(arr[i]==' ')
b++;
i++;
}
int newlen=i+1+b*2;
if(newlen>n)
return NULL;
int j=newlen-1,z=i;
while(z>=0)
{
while(arr[z]!=' ' && z>=0)
{
arr[j]=arr[z];
j--;
z--;
}
if(z<0)
{
break;
}
arr[j]='0';
arr[j-1]='2';
arr[j-2]='%';
j=j-3;
z=z-1;
}
return arr;
}
void main()
{
char s[100]="we are happy.";
printf("%s",getS(s,100));
}