Description The code to infer whether a string entered is a palindrome.If the output is "Yes". Otherwise output "No".
A palindrome is a string that reads and reads backwards. Inputoutputsample Inputabcddcbasample Outputyes
/* Copyright (c) 2014, Yantai University School of Computer * All rights reserved. * File name: Test.cpp * Chen Dani * Completion Date: June 1, 2015 * version number: v1.0 * * #include <iostream> #include <cstdio>using namespace s Td;int Main () { char a[81]; Gets (a); int i,n=0,s=0; for (i=0; a[i]!=0; i++) n++; for (i=0; i<n/2; i++) { if (a[i]==a[n-i-1]) s++; } if (S==N/2) cout<< "Yes" <<endl; else cout<< "No" <<endl; return 0;}
Experience: This time write more simple than the last write. The main thing is to think of a more ingenious method, this is progress!
So before you do the question, think about it with the mathematical thinking, there is no simple solution, this will be much easier! Keep trying.
C + + brush question--2802: Infer If a string is a palindrome