日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

2008--2009年北京航空航天大学计算机研究生机试真题

發(fā)布時(shí)間:2024/7/19 编程问答 88 豆豆
生活随笔 收集整理的這篇文章主要介紹了 2008--2009年北京航空航天大学计算机研究生机试真题 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

http://ac.jobdu.com/problem.php?pid=1165?字符串匹配

#include<iostream> #include<cstdio> #include<cstring> using namespace std;char str[1005][500],temp[1005][500],pattern[1005];inline bool pre_match(int j,int start,int end) {int i;for(i=start;i<=end;i++){if(temp[j][i]!=pattern[i])return false;}return true; } inline bool middle_match(int j,int start,int end) {int i;for(i=start+1;i<end;i++){if(temp[j][start]==pattern[i])return true;}return false; } inline bool post_match(int j,int start,int end) {int i,p;for(i=start+1,p=end+1;temp[j][i]!='\0' && pattern[p]!='\0' ;i++,p++){if(temp[j][i]!=pattern[p])return false;}return true; } int main(void) {int i,j,n,st,en;while(scanf("%d",&n)!=EOF){for(i=0;i<n;i++){scanf("%s",str[i]);strcpy(temp[i],str[i]);}for(i=0;i<n;i++){for(j=0;temp[i][j]!='\0';j++){if(temp[i][j]>='a') //將字符串中的字符全部轉(zhuǎn)換為大寫(xiě),數(shù)字則不變temp[i][j]-=32;}}scanf("%s",pattern);st=en=-1;for(i=0;pattern[i]!='\0';i++){if(pattern[i]>='a')pattern[i]-=32;if(pattern[i]=='[')st=i;else if(pattern[i]==']')en=i;}if(st==-1) //不存在中括號(hào)表示的模式匹配{for(i=0;i<n;i++){if(strcmp(temp[i],pattern)==0){printf("%d %s\n",i+1,str[i]);break;}}}else{for(i=0;i<n;i++){if(strlen(str[i]) != strlen(pattern) - (en - st) )continue;if(pre_match(i,0,st-1) && middle_match(i,st,en) && post_match(i,st,en)) //前綴、中間、后綴分別都匹配{printf("%d %s\n",i+1,str[i]);}}}}return 0; }

http://ac.jobdu.com/problem.php?pid=1168?字符串的查找刪除

#include<iostream> #include<cstdio> using namespace std; #include<string.h>char str[1000][1000],s[1000]; int slen;bool match(int j,int len,int index) {int i,p;for(i=j,p=0;i<j+len && p<slen;i++,p++){if(s[p]!=str[index][i]){if(s[p]-str[index][i]!=32 && str[index][i]-s[p]!=32) //大小寫(xiě)不敏感return false;}}return true; }int main(void) {int i,j,n=0,len;//freopen("a.txt","w",stdout);scanf("%s",s);slen=strlen(s);getchar();while(gets(str[n])){if(strcmp(str[n],"}")==0)break;n++;}for(i=0;i<=n;i++){len=strlen(str[i]);for(j=0;j<=len-slen;j++){if(str[i][j]==' ')continue;if(!match(j,slen,i)) //不匹配的話直接輸出printf("%c",str[i][j]);else //匹配的話直接跳過(guò),不輸出j=j+slen-1;}for(;j<len;j++)printf("%c",str[i][j]);printf("\n");}return 0; }



?

總結(jié)

以上是生活随笔為你收集整理的2008--2009年北京航空航天大学计算机研究生机试真题的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。