#include<stdio.h>
#include<string.h>
int main()
{
char s[100];
char p[100];
scanf("%s",s);
int l=strlen(s);
char last=s[l-1];
char last_two[2];
last_two[0]=s[l-2];
last_two[1]=s[l-1];
int i;
for(i = 0; s[i]; i++){
s[i] = tolower(s[i]);
}
strcpy(p,s);
if(strcmp(last_two,"ch")==0 || strcmp(last_two,"sh")==0 || last=='s')
{
p[l]='e';
p[l+1]='s';
p[l+2]='\0';
}
else if(last=='y')
{
p[l-1]='i';
p[l]='e';
p[l+1]='s';
p[l+2]='\0';
}
else
{
p[l]='s';
}
printf("%s %s",s,p);
return 0;
}
#include<string.h>
int main()
{
char s[100];
char p[100];
scanf("%s",s);
int l=strlen(s);
char last=s[l-1];
char last_two[2];
last_two[0]=s[l-2];
last_two[1]=s[l-1];
int i;
for(i = 0; s[i]; i++){
s[i] = tolower(s[i]);
}
strcpy(p,s);
if(strcmp(last_two,"ch")==0 || strcmp(last_two,"sh")==0 || last=='s')
{
p[l]='e';
p[l+1]='s';
p[l+2]='\0';
}
else if(last=='y')
{
p[l-1]='i';
p[l]='e';
p[l+1]='s';
p[l+2]='\0';
}
else
{
p[l]='s';
}
printf("%s %s",s,p);
return 0;
}
why are we not using & symbol for scanf statement?
ReplyDeleteCan you just explain why are you checking up==right?
ReplyDeletebecause the problem doesn't say that number of characters in row has to be equal to that of the no of characters in column
Please ask in the correct post to avoid confusion.
ReplyDeleteThe question says "the number of cells in the vertical and horizontal line of L shape is same".
As I mentioned before this problem can be simply solve by checking if the cell above and to the right are same as the element itself. For THIS SPECIFIC PROBLEM it will suffice.
i am extremely sorry for the inconvenience..
DeleteBut in skillrack its showing a infinite loop or time delay problem
and also in the example given the number of cells in the vertical and horizontal line of L shape is not same
DeleteWhich problem are you referring to?
DeleteI have tried to explain it in the video linked.
Deletesir what is ur e-mail id .i want to send u a code in wich i am facing .kindly help me.my e mail is deepak.khairwal2015@vit.ac.in
ReplyDeletekarth2512@gmail.com
Delete