Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
114573 | 谢绍澜 | 指针遍历字符串 | C++ | Accepted | 0 MS | 272 KB | 468 | 2025-03-22 17:08:25 |
#include<iostream> // cin\cout\endl #include<cstdio> //scanf()\printf() #include<cstring> // strcpy()\strcat()\strcmp()\strlen()\memset() #include<cmath> //sqrt()\pow()\abs()\ceil()\floor()\max()\min() using namespace std; int main(){ char a[500]; cin>>a; char *p; p=a; int l=strlen(a),s=0; char x=a[l-1]; for(int i=0;i<l;i++){ if(*p==x) s++; p++; } cout<<s; return 0; }