注册 登录
编程论坛 C++教室

解释一下 这个代码 越详细越好

herong881111 发布于 2010-10-20 15:02, 352 次点击
#include <iostream.h>
#include <string.h>
#define N6
char * binary (char*s)
{static char * pstr[N]={"const","double","enum","float","signed","unsigned"};
 int low,high,mid
 low=o
 high=N-1
 while(low<=high)
 {mid=(low+high)/2
 if (strcmp(s,pstr[mid])<0)}
 high=mid-1
 else if (strcmp(s,pstr[mid])>0)
 low=mid+1,
 else return(pstr[mid]);
 }
 return(0);
 }
void main()
{char*a,*find;
   cout<<"输入要查找的字符串:";
   cin.getline(find,80);
a=binary(find);
if(a!=o) cout<<"找到字符串"<<a<<endl;
else cout<<"没找到!"<<endl
}
0 回复
1