【无标题】

2019 计蒜客蓝桥杯
个人学习使用
代码1:

#include<string>
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n=100;
	int temp=0,sum=0;
	for(int i=1;i<=n;i++){
		temp=temp+i;
		sum=sum+temp;
	} 
	cout<<sum<<endl;
	
	cout<<"-----------------------"<<endl;
	
	char *p="abcde";
	char *q=(char*)malloc(strlen(p)+1);
	for(int i=0; p[i]- -*(p+i);i++){//指针技巧
		q[i]=p[i]; 
	}
//	q[i]=0;
	cout<<q<<endl;
	cout<<p<<endl;
	
	return 0;
}



代码2:

#include<bits/stdc++.h>
using namespace std;
int f(int m,int n){
	n=n%m;
	vector<int> v;
	for(;;){
		v.push_back(n);
		n*=10;
		n=n%m;
		if(n==0) return 0;
		if( find(v.begin(),v.end(),n)!=v.end() ){
	        //填入代码		
			return (int)(v.end()-find(v.begin(),v.end(),n));
			
		}
	}
}
int main(){
	int m,n;
	cin>>m>>n;
	cout<<f(n,m)<<endl;
	return 0;
} 

代码3:

#include<bits/stdc++.h>
using namespace std;

int main(){
	n 10e8
	nlogn 10e6
	nsqrt(n) 10e5
	n*n n 5000
	n*n*n 300
	2*n  25
	n! 11
	return 0;
} 

代码4:

#include<bits/stdc++.h>
using namespace std;

int main(){
	 int n;
	 cin>>n;
	 for(int i=1;i<=n;i++){
	 	string space=string(n-i,' ');
	 	string ch=string(2*i-1,'A'+i-1);//技巧而已 
	 	cout<<space+ch<<endl;
	 }

	return 0;
} 

代码5:

#include<bits/stdc++.h>
using namespace std; 
int main(){
	 char c;
	 cin>>c;
	 if(c>='A'&&c<='Z'){
	 	for(int i=1;i<=c-'A'+1;i++){
	 		
			for(int j=1;j<=c-'A'+1-i;j++){//注意ascll和字符数字的转化
	 			cout<<' ';
			}
			
			for(int j=1;j<=i;j++){
				cout<<(char)('A'+j-1);
			}
				
			for(int j=i-1;j>=1;j--){
			 cout<<(char)('A'+j-1);
			}
			cout<<endl;
		 }
	 }else{
	 
	 	for(int i=1;i<=c-'1'+1;i++){
	 		
			for(int j=1;j<=c-'1'+1-i;j++){
	 			cout<<' ';
			}
			
			for(int j=1;j<=i;j++){
				cout<<(char)('1'+j-1);
			}
				
			for(int j=i-1;j>=1;j--){
			 cout<<(char)('1'+j-1);
			}
			cout<<endl;
		    }	   
	 }
	return 0;
} 

代码6:

#include<bits/stdc++.h>
using namespace std;

int main(){
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			cout<<"+-";
		}
		cout<<"+"<<endl;
		for(int j=1;j<=m;j++){
			cout<<"|*";
		}
		cout<<"|"<<endl;	
		}
		for(int j=1;j<=m;j++){
			cout<<"+-";
		}
		cout<<"+"<<endl;
	return 0;
} 

代码7:

#include<bits/stdc++.h>
using namespace std;
char dest[25]={0};
int main(){
	char name[10];
	char *str="jisuanke";
	strcpy(name,str);
	cout<<name<<endl;
	cout<<" -------------------- "<<endl;
//	char dest[25]={0};
	char * str1="Hello",* str2=" ",* str3="jisuanke";
	strcat(dest,str1);
	strcat(dest,str2);
	strcat(dest,str3);
	cout<<dest<<endl;	
	return 0;
} 

代码8:

#include<bits/stdc++.h>
using namespace std;

int main(){
	char *str1="cd",* str2="abc";
	int res=strcmp(str1,str2);
	if(res>0){
		cout<<"1>2";	
	}else if(res==0){
		cout<<"1==2";
	}else{
		cout<<"1<2";
	}
	return 0;
} 

代码9:

#include<bits/stdc++.h>
using namespace std;
char res[5000000];
int main(){
	int n;
	cin>>n;
	int len=0;
	for(int i=1;i<=n;i++){
	//填入 
		strcat(res+len+1,res);
		res[len]='A'+i-1;
		len=strlen(res);
	}
	cout<<res<<endl;
	return 0;
} 

代码10:`

#include<bits/stdc++.h>
using namespace std;
char s1[1005],s2[1005];
int main(){
	fgets(s1,1004,stdin);
	fgets(s2,1004,stdin);
	int len1=strlen(s1)-1,len2=strlen(s2)-1 ;
	int ans=0;
	for(int i=0;i+len2-1<len1;i++){
		bool match=true;
		for(int j=0;j<len2;j++){
			if(s1[i+j]!=s2[j])
			match=false;
			break;
		}
		if(match){
		ans++;
		} 
	}
	cout<<ans;
	
	return 0; 
	
} 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值