Judging whether the text is written badlyCodeCreate a flag.
Question
Description: a string of no more than 1000 characters is provided. It is used to determine whether the string is a forward-read or reverse-read string. Input: enter a string of no more than 1000 characters. Output: multiple groups of test data may exist. For each group of data, if it is a return string, "Yes!" Is output !", Otherwise, "No!" Is output! ". Sample input: hellollehhelloworld sample output: Yes! No!
Array Implementation
# Include <stdio. h> # include <stdlib. h> # include <string. h> int main () {char STR [1001]; int Len, flag, I; while (scanf ("% s", STR )! = EOF) {flag = 1; Len = strlen (STR); for (I = 0; I <Len/2; I ++) {If (STR [I]! = STR [Len-1-I]) {flag = 0; break ;}} if (FLAG) printf ("Yes! \ N "); elseprintf (" No! \ N ") ;}return 0 ;}
Pointer operation
# include
# include
# include
void issymmetrical (char * Str) {char * begin, * end; int flag, Len = strlen (STR); For (begin = STR, end = STR + len-1, flag = 1; begin <= end; begin ++, end --) {If (* begin! = * End) {flag = 0; break;} If (FLAG) printf ("Yes! \ N "); else printf (" No! \ N ") ;}int main (void) {char STR [1001]; while (gets (STR) {is1_rical (STR) ;}return 0 ;} /*************************************** * *********************** problem: 1192 User: wangzhengyi language: C result: accepted time: 10 MS memory: 912 KB ************************************** * *************************/