Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
41019 | 董宇家 | 指针遍历字符串 | C++ | Accepted | 1 MS | 272 KB | 265 | 2022-10-23 12:22:28 |
#include<iostream> #include<cstring> using namespace std; int main(){ char str[31]; cin>>str; char *p; char c; int x=0; c=str[strlen(str)-1]; p=str; for(int i=0;i<strlen(str);i++){ if(*p==c){ x++; } p++; } cout<<x; return 0; }