高仿模拟练习,补全 found 标记处空缺,答案点击按钮展开
fun返回字符串中第一个数字字符的下标,没有数字返回‑1,请补全found。
#include <stdio.h>
int fun(char s[])
{
int i=0;
while(s[i]!='\0')
{
/**********found**********/
if(s[i]>='0' && ___1___ )
/**********found**********/
return ___2___;
i++;
}
/**********found**********/
return ___3___;
}
int main()
{
char str[100];
gets(str);
printf("index=%d\n",fun(str));
return 0;
}
s[i]<='9'
i
-1
第1空判断当前字符是否为数字;第2空找到返回当前下标i;第3空遍历结束没找到返回‑1。输入ab3cd,输出index=2。