Count a character
此页面需较新浏览器(支持 SharedArrayBuffer)。请升级 Chrome、Edge、Firefox 或 Safari 至最新版本。
统计某个字符
返回某个字符在 C 字符串中出现的次数。遍历字符直到空字符为止,每当当前字符与 target 相同时就加 1。
难度 3/5 · 今日首次完成可获 200 金币及少量额外奖励
Complete int count_char(const char *s, char target) to return how many times target appears in the C-string s.
点击“运行”查看此处输出。