![]() |
#2
rjsp2017-12-07 14:07
|

#include<iostream>
using namespace std;
const int N=5;
void f(char(*p)[20],char*q);
void main()
{
char str[N][20],(*p)[20]=str;
char*ptfind="c++";
int i;
for(i=0;i<N;i++)
gets(*(p+i));
f(str,ptfind);
}
void f(char(*p)[20],char*q)
{
int j;
for(j=0;j<N;j++)
if(*(p+j)[0]==*q)
cout<<"找到了"<<endl;
else
cout<<"没找到"<<endl;
for(j=0;j<N;j++)
cout<<*(p+j)[0]<<endl;
}
我的问题是为什么using namespace std;
const int N=5;
void f(char(*p)[20],char*q);
void main()
{
char str[N][20],(*p)[20]=str;
char*ptfind="c++";
int i;
for(i=0;i<N;i++)
gets(*(p+i));
f(str,ptfind);
}
void f(char(*p)[20],char*q)
{
int j;
for(j=0;j<N;j++)
if(*(p+j)[0]==*q)
cout<<"找到了"<<endl;
else
cout<<"没找到"<<endl;
for(j=0;j<N;j++)
cout<<*(p+j)[0]<<endl;
}
if(*(p+j)[0]==*q)
我只取每行的一个字符与“c++“比较也能输出找到了,我把输出结果截了屏。只有本站会员才能查看附件,请 登录
只有本站会员才能查看附件,请 登录