gpt4 book ai didi

c - 如何在c中的另一个字符串中找到字符串的给定字符的索引?

转载 作者:太空宇宙 更新时间:2023-11-04 00:00:47 24 4
gpt4 key购买 nike

<分区>

char string[5][5]={{'a','l','p','h','b'},{'c','d','e','f','g'},
{'i','j','k','m','n'},{'o','q','r','s','t'},
{'u','v','w','x','y'}};
char strsearch[100];
int rowindex[100];
int colindex[100];
printf("\nEnter String=");
gets(strsearch);
int iIndex,jIndex=0;
int count=0;
int row,column=0;
for(row=0;row<5;row++)
{
for(column=0;column<5;column++)
{
if(string[row][column]==strsearch[i])
{
rowindex[iIndex]=row;
colindex[jIndex]=column;
iIndex++;
jIndex++;
count++;
i++;
//printf("%d",count);
}
}
}

for(iIndex=0;iIndex<count;iIndex++)
{
printf("row=%d",rowindex[iIndex]);
printf("\ncol=%d",colindex[iIndex]);
}

我已经像上面那样完成了预期的输出应该如下所示。输出应该是:

    Enter String=mona
row=2,3,2,0 //index of row of character 'm','o','n','a'
column=3,0,4,0 ////index of column of character 'm','o','n','a'

但是它不打印任何东西。这有什么问题吗?

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com