原址http://blog.csdn.net/v_JULY_v/article/details/6347454
其中的HASH方法和BITMAP方法感觉很实用
// StringInclude.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include "stdio.h" bool cmp() { char* strOne = "ABCDEFGHLMNOPQRS"; char* strTwo = "DCGSRQPOMZ"; int bitmap = 0; while(*strOne) { bitmap |= 1 << (*strOne - 'A'); strOne++; } while(*strTwo) { if ((bitmap & 1 << (*strTwo - 'A')) == 0) return false; strTwo++; } return true; } int main(int argc, char* argv[]) { printf("%s\n", cmp()?"yes":"no"); return 0; }