#include
int findch(char *s, char c)
{
int i;
for(i = 0; s[i]; i++)
if(s[i] == c) break;
if(s[i] == c) return i;
return -1;
}
int main()
{
char s[100];
char c;
scanf("%s",s);
getchar();
c=getchar();
printf("%d\n",findch(s,c));
return 0;
}
#include
#include
int main(void){
char array[] = "akjierfjcneofjlkj12321";
char c;
int i = 0;
scanf("%c", &c);
while(array[i] != '\0' && array[i] != c) i++;
if(array[i] == '\0') i = -1;
printf("%c index is %d", c , i);
return 0;
}
你主要看看c的输出输入函数还有数组和循环的配合使用运算符等····
这都是基础的东西····