weixin_34121722 于 2016.02.29 19:35 提问

#include
#include
using namespace std;
int main(){
char str1[80], str2[80];
char pc1 = str1, *pc2 = str2;
cin >> pc1 >> pc2;
char a[80][80];
for (unsigned i = 0; i<strlen(str1) - strlen(str2) + 1; i++){
for (unsigned j = 0; j<strlen(str2); j++)
a[i][j] = *(pc1 + i + j);
}
char(*pa)[80];
pa = a;
for (unsigned i = 0; i<strlen(str1) - strlen(str2) + 1; i++){
if (strcmp(
(pa + i), str2) == 0)
cout << str1[i];

``````}
``````

}

3个回答

devmiao      2016.02.29 22:04
u013596119   2016.02.29 23:05

`````` #include <iostream>
#include "string.h"
using namespace std;
int main(){
char str1[80], str2[80];
char *pc1 = str1;
char *pc2 = str2;
cin >> pc1 >> pc2;
char a[80][80];
for (unsigned i = 0; i<strlen(str1) - strlen(str2) + 1; i++){
for (unsigned j = 0; j<strlen(str2); j++)
a[i][j] = *(pc1 + i + j);
}
char (*pa)[80];
pa = a;
for (unsigned i = 0; i<strlen(str1) - strlen(str2) + 1; i++){
if (strcmp((*pa + i), str2) == 0)
cout << str1[i];
}
}
``````
apprentices   2016.03.03 14:52