任务是更改第一句中所有与第二句中的单词相似的单词的寄存器。寄存器应与第二句中的相同。
这是我到目前为止获得的代码,但是我有点卡住了。 也许有更简单的方法可以不用数组来做到这一点。谢谢。
int main()
{
char input[100];
char input2[100];
char cheking[100];
char cheking2[100]
int i, j, j1, j2, l; //COUNTERS
int k;
printf("Please, enter the 1st sentence:\n");
for (i = 0; (input[i] = getchar()) != '\n'; i++)
{
;
}
printf("Please, enter the 2nd sentence:\n");
for (i = 0; (input2[i] = getchar()) != '\n'; i++)
{
;
}
i = 0;
j1 = strlen(input) - 1; //CHECK AFTER
j2 = strlen(input2) - 1;
//do
for (i = 0; i < j1; i++) //I didn't realise it for every word of the 1st sentence
for (k = 0; (input[k] != ' '); k++)
{
checking[k] = tolower(input[k]);
}
for (i = 0; i < j2; i++)
{
for (k = 0; (input2[k] != '\n'); k++)
{
checking2[k] = tolower(input2[k]);
}
}
for(i = 0; i < j2; i++)
{
for (j = 0; (checking2[j] != ' '), j++)
{
if (cheking1[j] != cheking2[j])
{
i++;
j = 0;
k = 1;
}
else (k = 0);
}
if (k == 1)
for(i; (input[i] != ' '); i++) //don't know how to change word to that it should be
{
}
}
//while ((input[i] != '\n') || (input[2] != '\n');
getch();
return 0;
}