当前位置:网站首页>【无标题】
【无标题】
2022-04-22 11:04:00 【悄悄笙箫】
#include <bits/stdc++.h>
#define N 105
using namespace std;
int a[N], n;
int main() {
cin>>n;
int num=0;
int result[n];
for (int i =0;i<n;i++){
cin>>a[i];
}
for(int i=0;i<n;i++)
{
for (int j=0;j<n;j++){
for(int k=j+1;k<n;k++){
if( (i!=j)&(j!=k)){
if(a[i]==a[j]+a[k]){
num+=1;
}
}
}
}
}
cout<<num;
return 0;
}
#include <bits/stdc++.h>
#define N 105
using namespace std;
int a[N], n;
bool check(int i) {
for (int j = 0; j < n; ++j)
for (int k = j + 1; k < n; ++k)
if (a[j] + a[k] == a[i]) return true;
return false;
}
int main() {
scanf("%d", &n);
for (int i = 0; i < n; ++i)
scanf("%d", &a[i]);
int sum = 0;
for (int i = 0; i < n; ++i)
if (check(i)) ++sum; // 也可以是 sum += check(i)
printf("%d\n", sum);
return 0;
}

2排列枚举问题

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std ;
int main(){
int a,b,c;
cin>>a>>b>>c;
int arr[10]={1,2,3,4,5,6,7,8,9,10};
bool check=false;
do{
int num1=arr[0]*100+arr[1]*10+arr[2];
int num2=arr[3]*100+arr[4]*10+arr[5];
int num3=arr[6]*100+arr[7]*10+arr[8];
if (a*num2==b*num1&&c*num2==b*num3){
cout<<num1<<" "<<num2<<" "<<num3<<endl;
check=true;
}
}while(next_permutation(arr,arr+9));
if(!check){
cout<<"No!!!"<<endl;
}
return 0 ;
}
冒泡排序和选择排序有什么区别??
插入排序怎么理解

不是很理解,还是不行
#include <bits/stdc++.h>
using namespace std;
int main() {
// 请补全代码,实现题目功能
int n;
cin>>n;
int a[n];
for (int i=1;i<=n;i++){
cin>>a[i];
}
for (int i=2;i<=n;i++){
int j;int x=a[i];
for(j=i;j>1&a[j-1]>a[j];j--){
a[j]=a[j-1];
}
// a[j]=x;
}
sort(a+1,a+n+1);
for (int i=1;i<=n;i++){
cout<<a[i]<<" ";
}
return 0;
}
版权声明
本文为[悄悄笙箫]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_43332626/article/details/124298985
边栏推荐
- qDebug()打印调试信息
- 2022年中科磐云——Wb安全应用 flag
- 滚动条样式修改
- Php get IP Limits submissions in minutes for verification code Getting too frequently
- 图解文件系统——我见过讲文件系统讲的最好的文章了
- As a half salted fish in the workplace, how can we do well in test management
- 【leetcode】145.二叉树的后序遍历
- 三六零发布年报:实现营业收入约108.86亿元 安全业务增长超70%
- Analysis of module d electronic answer card of "network security" (secondary vocational group) in 2022 skill competition - new vulnerabilities
- Right click menu of cesium map (cesium chapter. 72)
猜你喜欢

Low sidelobe weighting processing of phased array antenna

How much do you know about ADB command? Here comes the detailed ADB command

什么样的项目适合做自动化测试?

Network security -- attack defense confrontation

创建对象内存分析与继承

【leetcode】145. Binary Tree Postorder Traversal

女生学软件测试难不难?

Chat chat app Lesson 6 creating a main chat static page

Ampere computing releases the computing power of observation cloud "core" and jointly promotes the development of observability

Spark 3. Source code analysis of wscg mechanism based on X
随机推荐
How do enterprises calculate customer lifetime value?
【leetcode】94.二叉树的中序遍历
[leetcode] the first mock exam of two tree traversal iteration method.
How can Futures Network account opening be reliable? Fund security!
Batch update software and security optimization (taking openssh as an example) -- the road of building a dream
Since when has the software test interview been so difficult?
Robot system design coppeliasim simulation
ES6学习笔记之4数值表示法有关数值的扩展(8进制表示法)(转载,备忘非我原创)
postman接口测试工具视频教程,零基础入门到高手毕业
Redis 环境安装
JS get the width and height of DOM element
软件维护习题精讲
中职网络安全attack.pcapng数据包的flag
DevSecOps软件研发安全实践——设计篇
【leetcode】94. Middle order traversal of binary tree
Use bitnami PostgreSQL docker image to quickly set up stream replication clusters
Create object memory analysis and inheritance
Right click menu of cesium map (cesium chapter. 72)
qDebug()打印调试信息
As a half salted fish in the workplace, how can we do well in test management