Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
14900 张昊然 指针遍历字符串 C++ Accepted 3 MS 720 KB 273 2021-07-08 19:47:43

Tests(2/2):


Code:

#include <iostream> #include <cstring> using namespace std; char s[35]; int main() { cin >> s; char *p = s; char c = s[strlen(s) - 1]; int cnt = 0; for (int i = 0; i < strlen(s); i++) { if (*(p + i) == c) { cnt++; } } cout << cnt; return 0; }