本題要求實現乙個函式,統計給定字串中英文本母、空格或回車、數字字元和其他字元的個數。
函式介面定義:
其中void
stringcount
(char s)
;
char s
是使用者傳入的字串。函式stringcount
須在一行內按照
letter = 英文本母個數, blank = 空格或回車個數, digit = 數字字元個數, other = 其他字元個數
的格式輸出。
裁判測試程式樣例:
輸入樣例:#include
#define maxs 15
void
stringcount
(char s)
;void
readstring
(char s)
;/* 由裁判實現,略去不表 */
intmain()
/* your function will be put here */
輸出樣例:az &
09 az
letter =
4, blank =
3, digit =
2, other =
1
void
stringcount
(char s)
else
if(s[i]
==' '
|| s[i]
=='\n'
)//空格/回車
else
if(s[i]
>=
'0'&& s[i]
<=
'9')
else
i++;}
printf
("letter = %d, blank = %d, digit = %d, other = %d\n"
, letter, blank, digit, other)
;}
習題6 1 分類統計字元個數
本題要求實現乙個函式,統計給定字串中英文本母 空格或回車 數字字元和其他字元的個數。函式介面定義 void stringcount char s 其中 char s 是使用者傳入的字串。函式stringcount須在一行內按照 letter 英文本母個數,blank 空格或回車個數,digit 數字...
習題6 1 分類統計字元個數
void stringcount char s 其中 char s 是使用者傳入的字串。函式stringcount須在一行內按照 letter 英文本母個數,blank 空格或回車個數,digit 數字字元個數,other 其他字元個數 的格式輸出。include define maxs 15 vo...
習題6 1 分類統計字元個數
習題6 1 分類統計字元個數 15 分 本題要求實現乙個函式,統計給定字串中英文本母 空格或回車 數字字元和其他字元的個數。void stringcount char s 其中char s是使用者傳入的字串。函式stringcount須在一行內按照 letter 英文本母個數,blank 空格或回車...