Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
187 邓小龙 利用指针编写strlen函数 C++ Accepted 0 MS 264 KB 415 2022-07-21 18:03:18

Tests(10/10):


Code:

#include<iostream> #include<cstring> using namespace std; int s(char *p) //定义字符指针p { int cnt=0; while(*p!='\0') //什么时候结束循环,在一段字符串中是以'\0'结束的 { cnt++; //计算有多少个字符的 p++; //移位 } return cnt; } int main(){ char a[1001]; cin>>a; cout<<s(a); return 0; }