⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 d3.cpp

📁 此程序可用于匹配正则表达的字符串
💻 CPP
字号:
#include<iostream>
#include<string>
#include<fstream>
using namespace::std;
voidl compatible(char* str1,char*str2){
	int i;
	if(strlen(str1)==1&&strlen(str2)>1) return (strlen(str2)==2&&str2[0]=='*'&&str2[1]==str1[0]);
	if(strlen(str2)==1) switch (str2[0]){
		case '?': return true;break;
		case'*': return true;break;
		default: return(str1[0]==str2[0]);
	}
    if(str2[0]!='*'&&str2[0]!='?')
		return (str1[0]==str2[0]&&compatible(str1+1,str2+1));
    if(str2[0]=='?')
		return compatible(str1+1,str2+1);
   if(str2[0]=='*') for(i=0;i<strlen(str1);i++)
	{
		if (str1[i]==str2[1]) {return compatible(str1+i,str2+1);break;}
	}
   return false;

}
void main(void){
	char (*dic)[80]=new char[100][80],temp[100];
	int i=0,j;
	ifstream extract("dictionary.txt",ios_base::in);
	while(!extract.eof()) {extract.getline(dic[i],80,' ');i++;}
	cout<<"please input the word you want to find:"<<endl;
    cin>>temp;
	for(j=0;j<=i;j++)
		if(compatible(dic[j],temp)) cout<<dic[j]<<' ' ;

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -