代码2

2026年01月09日
// 万能头文件:包含C++所有标准库(无需单独引入queue、iostream等)
#include <bits/stdc++.h>
// 使用std命名空间:简化代码,避免写std::前缀
using namespace std;

int main1(){
	char a[100]="hello c++";
	char b[100];	
	strcpy(b,a);//复制后面的到前面 (字符串) 
	cout<<b<<endl;	
	cout<<strlen(a)<<endl;//返回字符串的长度 	
	strupr(a); //转化为大写 
	cout<<a<<endl;	
	strlwr(a); //转化为小写 
	cout<<a<<endl;	
	char c[100]="a"; 
	char d[100]="abb";
	cout<<strcmp(c,d)<<endl;//比较的是每个位置上字符的ASCII码值,得出结果就不再比较
	//正整数 前>后 
	//负整数 前<后 
	//0 前后相等 	
	strcat(d,c);// 连接两个字符串(前+后)
	cout<<d<<endl;	
	char e[100]="aabbcc";//子串:包含的意思 
	char f[100]="aa"; 
	char g[100]="abc"; 
 	//NULL代表空 ,返回空则不包含 
	cout<<"结果="<<(strstr(e,g)==NULL)<<endl;
	return 0;
} 

int main2(){
	char a[100];
	char b[100];
	cin>>a>>b;
	
	if(strstr(a,b)!=NULL){
		cout<<b<<" is substring of "<<a<<endl;
	}else if(strstr(b,a)!=NULL){
		cout<<a<<" is substring of "<<b<<endl;
	}else{
		cout<<"No substring"<<endl;
	}
	return 0;
} 

int main(){
	char a[100];
	cin >> a;
	
	int n = strlen(a);
	bool flag = true;
	
	for(int i = 0;i<n;i++){
		if(a[i]!=a[n-1-i]){//前与后比较 
			flag = false;
		}
	}
	
	if(flag){
		cout<<"TRUE"<<endl;
	} else{
		cout<<"FALSE"<<endl;
	}
	
	return 0;
}