编程一小时2023.5.22

1.

#include<bits/stdc++.h>
using namespace std;
int a[11],i;
int main()
{
for(i=1;i<=10;i++)cin>>a[i];
sort(a+1,a+10+1);
for(i=10;i>=1;i--)
if(a[i]%2!=0)cout<<a[i]<<' ';
for(i=1;i<=10;i++)
if(a[i]%2==0)cout<<a[i]<<' ';
}

2.

#include <iostream>
#include <cstring>
using namespace std;
const int N=10010;
char str1[N],str2[N];
int f[N];
int alen,blen;
int maxv;

int main(){
scanf("%s%s",str1+1,str2+1);
alen=strlen(str1+1);
blen=strlen(str2+1);
for(int i=1;i<=alen;i++){
for(int j=blen;j>=1;j--){
if(str1[i]==str2[j] && isalpha(str1[i]) && isalpha(str2[j]))f[j]=f[j-1]+1;
else f[j]=0;
maxv=max(maxv,f[j]);
}
}
cout<<maxv;
return 0;
}

3.

#include<iostream>

using namespace std;

int main()
{
int n;
cin >> n;
while (n --)
{
int m, a[100];
cin >> m;
for (int i = 0; i < m; i ++) cin >> a[i];
int count = 0;
for (int i = 0; i < m; i ++)
for (int j = 0; j < m; j ++)
for (int k = 0; k < m; k ++)
if (a[i] + a[j] == a[k])
count ++;
cout << count << '\n';
}

return 0;
}

 

posted @   Verneyyx  阅读(14)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
点击右上角即可分享
微信分享提示