#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
/* 判断字符ch有无在arr数组里存在,存在返回真,反之返回假 */
bool is_contain(char ch, char arr[], int len);
/* 判断短字符串S中的所有字符是否在长字符串T中全部出现 */
bool func(char long_t[], int len_long, char short_t[], int len_short);
int main() {
char long_t[200], short_t[199];
bool ret;
scanf("%s", short_t);
scanf("%s", long_t);
short_t[strcspn(short_t, "\n")] = '\0';
long_t[strcspn(long_t, "\n")] = '\0';
int len_long = strlen(long_t);
int len_short = strlen(short_t);
ret = func(long_t, len_long, short_t, len_short);
if (ret)
printf("true\n");
else {
printf("false\n");
}
return 0;
}
/* 判断字符ch有无在arr数组里存在,存在返回真,反之返回假 */
bool is_contain(char ch, char arr[], int len) {
bool ret = false;
for (int i = 0; i < len; i++) {
if (ch == arr[i]){
ret = true;
break;
}
}
return ret;
}
bool func(char long_t[], int len_long, char short_t[], int len_short) {
if (len_long > 200 || len_short < 1)
return false;
if (len_long < len_short)
return false;
int j = 0;
bool ret = true;
while (short_t[j] != '\0') {
ret = is_contain(short_t[j], long_t, len_long);
if (!ret) {
// printf("short_t[%d]=%c\t", j, short_t[j]); //debug
ret = false;
break;
}
j++;
}
return ret;
}
#include <stdio.h>
#include<string.h>
int main() {
char str1[200], str2[200];
while (scanf("%s%s", str1, str2) != EOF) {
int num1[26] = {0}, num2[26] = {0}, flag = 1;
for (int i = 0; i < strlen(str1); i++) {
num1[str1[i] - 97]++;
}
for (int i = 0; i < strlen(str2); i++) {
num2[str2[i] - 97]++;
}
for (int i = 0; i < 26; i++) {
if (num1[i] && !num2[i]) {
flag = 0;
}
}
printf("%s\n", flag == 1 ? "true" : "false");
}
return 0;
} #include <stdio.h>
#include <string.h>
int main() {
char arr1[200];
char arr2[200];
int i, j;
gets(arr1);
gets(arr2);
int len1 = strlen(arr1);
int len2 = strlen(arr2);
int count=0;
for (i = 0; i < len1; i++)
{
for (j = 0; j < len2; j++) {
if (arr1[i] == arr2[j]) {
count++;
break;
}
}
}
if (count==len1) {
printf("true");
}
else {
printf("false");
}
return 0;
} #include <stdio.h>
#include <string.h>
int main() {
int bz[26] = {0};
char ss[200],ls[300];
scanf("%s",ss);
scanf("%s",ls);
int m = strlen(ss), n = strlen(ls), result = 1;
for(int i = 0; i<n; i++){
bz[ls[i] - 'a'] = 1;
}
int sum = 0;
for(int i = 0;i<26; i++) sum += bz[i];
if(sum == 26){printf("true");return 0;}
for(int i = 0; i<m; i++){
if(bz[ss[i] - 'a'] != 1){printf("false");return 0;}
}
printf("true");
return 0;
} #include <stdio.h>
void judge(char*T,char*S);
int main() {
char S[200],T[201];
gets(S);
gets(T);
judge(T,S);
return 0;
}
void judge(char*T,char*S){
int exist[128]={0};
for(int i=0;i<strlen(T);i++)
{
exist[T[i]]=1;
}
int i=0;
while (exist[S[i]]&&i<strlen(S)) {
i++;
}
if(i==strlen(S)) printf("true\n");
else printf("false\n");
} /* 利用strstr 函数非常简单!*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main()
{
char s[200], l[200];
while(scanf("%s", s) != EOF)
{
scanf("%s", l);
char *ret; //子串第一次出现的位置
ret = strstr(l, s);
if(ret != NULL)
printf("true");
else
printf("false");
}
return 0;
}
#include <stdio.h>
int main()
{
char strS[200];
char strT[200];
scanf("%s %s",strS,strT);
int lenS = strlen(strS);
int lenT = strlen(strT);
int i,j;
int samenum = 0;//字符串S中能在字符串T中找到的字符的个数
//用能找到相同字符的个数 == 字符串S的字符数来判断
for(i=0;i<lenS;i++)
{
for(j=0;j<lenT;j++)
{
if(strS[i] == strT[j])
{
samenum++;
break;
}
}
}
if(samenum == lenS)
printf("true");
else
printf("false");
return 0;
} #include<stdio.h>
#include<string.h>
int main()
{
char arr1[200] = { 0 };
char arr2[200] = { 0 };
while (gets(arr1))
{
gets(arr2);
int count = 0;
int len1 = strlen(arr1);
int len2 = strlen(arr2);
for (int i = 0; i < len1; i++)
{
for (int j = 0; j < len2; j++)
{
if (arr1[i]-arr2[j]==0)
{
count++;
break;
}
}
}
if(count==len1)
printf("true\n");
else
printf("false\n");
}
return 0;
} #include<stdio.h>
#include<string.h>
int main()
{
char str[200]={0};
char ret[200]={0};
int mat[26]={0};
scanf("%s",str);
scanf("%s",ret);
if(strlen(str)>strlen(ret))
{
printf("false");
return 0;
}
for(int i=0;i<strlen(str);i++)
{
int temp=(int)str[i]-97;
if(mat[temp]!=1)
mat[temp]++;
}
for(int i=0;i<strlen(ret);i++)
{
int temp=(int)ret[i]-97;
mat[temp]--;
}
for(int i=0;i<26;i++)
{
if(mat[i]>0)
{
printf("false");
return 0;
}
}
printf("true");
return 0;
} // 暴力解
#include <stdio.h>
#include <string.h>
int main(void)
{
char longStr[1024] = {'\0'};
char shortStr[512] = {'\0'};
while (scanf("%s%s", shortStr, longStr) != EOF) {
for (int i = 0; i < strlen(shortStr); i++) {
int flag = 0;
for (int j = 0; j < strlen(longStr); j++) {
if (shortStr[i] == longStr[j]) {
flag = 1;
break;
}
}
if (!flag) {
printf("false\n");
goto OUT; // 进入下一轮循环
}
}
printf("true\n");
OUT:
; // 空语句,进入下一轮循环
}
return 0;
}