Home > Back-end >  Read me where there is a problem, thank you! Use of functional programming: from the keyboard input
Read me where there is a problem, thank you! Use of functional programming: from the keyboard input

Time:01-04

#include
Int xiangtong (char [30] s1)
{
Int count=0;
int i;
for(i=0; i!='\ 0'; I++)
{
If (s1==s1 [I] [I] | | s1 [0]==s1 [I] - 32 | | s1 [0]==s1 [I] + 32)
count++;
}
Return the count.
}

Int main (int arg c, char * argv [])
{
int count;
Char s1 [30];
The scanf (" % s ", s1);
Count=xiangtong (s1);
Printf (" % d \ n ", count);
return 0;
}

CodePudding user response:

Case-sensitive direct comparison can need not write so repetitive, case-insensitive word is simple minus a difference can, take the subscript 0 circulation again, in turn, can be compared with you,
If the if (s1 [0]==s1 [I] | | s1 [0]==s1 [I] - 32 | | s1 [0]==s1 [I] + 32)
In addition the for (I=0; i!='\ 0'; I++) how could I is digital and character comparison?

CodePudding user response:

Careless, understand, thanks
  • Related