老赵的公开课

/*注释的代码,可添加*/
#include<stdio.h>
#include<string.h>
bool sysmetric(char *s){
	int n=strlen(s);
	for(int i=0;i<n/2;i++){
		if(s[i]!=s[n-1-i])
		return false;
	}
	return true;
}
int main(){
	char s[1000];
	scanf("%s",s);
	//int n=strlen(s);
	printf("%d\n",sysmetric(s));
	//if(n%2==0 and n>0 and sysmetric(s)){
		//s[n>>1]=0;
		//printf("%s\n",s);
	//}
	return 0;
}
#include<bits/stdc++.h>
using namespace std;
bool sysmetric(string s){
	string t=s;
	reverse(t.begin(),t.end());
	return s==t;
}
int main(){
	string s;
	cin>>s;
//	cout<<(s+s)<<endl;
//	reverse(s.begin(),s.end());
//	cout<<s<<endl;
	cout<<sysmetric(s)<<endl;
	if(s.size()%2==0 and s.size()>0 and sysmetric(s)){
		s=s.substr(0,s.size()/2);
		cout<<s<<endl;
	}
	return 0;
}
#include<bits/stdc++.h>
using namespace std;
int main(){
	char s[1000]="to know everything is to know nothing";
	char t[1000]="to";
	char *pos;
	pos=strstr(s,t);
	if(pos!=NULL){
		cout<<(pos-s)<<endl;
	}
//	pos+=strlen(t);//随意加数字,只要不在原位就行 
//	pos=strstr(pos,t);
//	if(pos!=NULL){
//		cout<<(pos-s)<<endl;
//	}
	return 0;
}
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s("to know everything is to know nothing");
	string t="to";
	int pos=s.find(t);
	if(pos==string::npos){
		cout<<"not find!"<<endl;
	}
	else{
		cout<<pos<<endl;
	}
	pos=s.find(t,pos+t.size());
	cout<<pos<<endl;
	return 0;
}
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n=123456,m;
	char buffer[100];
	sprintf(buffer,"%d%d",n%10,n/10);
	sscanf(buffer,"%d",&m);
	printf("%d\n",m);
	return 0;
}
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n=123456,m;
	ostringstream oss;
	oss<<n%10<<n/10;
	cout<<oss.str()<<endl;
	return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值