[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4756: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3891)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4758: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3891)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4759: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3891)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4760: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3891)
Dev Skill Forum • View topic - Palindrome(Beginner )

Palindrome(Beginner )

Dev Skill archived problems can be discussed here.

Palindrome(Beginner )

by akib9ctg » Thu Jul 21, 2016 12:35 pm

এই problem টার এই কোডটাতে কি সমস্যা হচ্ছে। যার কারনে wrong answer আস্তেছে বারবার। যদি কেও একটু বলতেন?

Beginner Beginners Problems > Ad-hoc

A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward or forward.

We want you to write a program that can check whether a given input is palindrome or not. The input will only contain English alphabets and digits. Remember, in this task, uppercase and lowercase letter count as same.

Input:
Input starts with an integer T (≤ 30), denoting the number of test cases. Each test case will have one line containing the text to test.

Output:
For each test case, print either “Yes” (without quotes) or “No” (without quotes). If the input text is palindrome then print “Yes”, otherwise print “No”

Sample Input
3
abababa
ababab
1EYE1
Sample Output
Yes
No
Yes




CODE:
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
int i,c,l,t,ck,m;
string a;
scanf("%d",&t);
getchar();
for(m=1; m<=t; m++)
{
cin>>a;
ck=0;
c=a.size();
for(i=0; a[i]; i++)
{
if(isupper(a[i]))
a[i]=tolower(a[i]);

}

for(i=0,l=c-1; i<c/2; i++,l--)
{
if(a[i]==a[l] )
ck=1;
else
{
ck=0;
break;
}
}
if(ck==1)
printf("Yes\n");
else
printf("No\n");
}
return 0;
}
 
Posts: 2
Joined: Thu Jul 21, 2016 12:21 pm

Re: Palindrome(Beginner )

by devskill » Thu Jul 21, 2016 8:29 pm

User avatar
Site Admin
 
Posts: 118
Joined: Tue Feb 02, 2016 10:24 pm

Re: Palindrome(Beginner )

by akib9ctg » Sat Jul 23, 2016 12:25 am

Thank you
 
Posts: 2
Joined: Thu Jul 21, 2016 12:21 pm

Palindrome(Beginner )

by raskin » Wed Jul 27, 2016 9:10 pm

 
Posts: 1
Joined: Wed Jul 27, 2016 8:56 pm

Re: Palindrome(Beginner )

by devskill » Thu Jul 28, 2016 7:00 am

It seems like the code you have posted here, you have commented out input taking and instead hard coded your input. Can you please provide your real code?

For example,
for the above test I/O in this post:

2
u
1

your output is:
Yes
No
Yes

But should be:
Yes
Yes

please read other post and check your code before you post. :)
User avatar
Site Admin
 
Posts: 118
Joined: Tue Feb 02, 2016 10:24 pm


Who is online
Users browsing this forum: No registered users and 1 guest
cron