判断字符串b是否在a中
1 #include "stdafx.h" 2 #include<stdio.h> 3 #include <string> 4 using namespace std; 5 int _tmain(int argc, _TCHAR* argv[]) 6 { 7 string a,b; 8 printf("输入两个数:"); 9 scanf("%c,%c",&a,&b); 10 for(int i=0;i<a.length()-b.length();i++) 11 { 12 if(b==a.substr(i,b.length())) 13 { 14 printf("是,在第%d位",i+1); 15 system("pause"); 16 } 17 else 18 { 19 printf("否"); 20 } 21 } 22 system("pause"); 23 24 }
浙公网安备 33010602011771号