当前位置:网站首页>*3-1 CCF 2014-09-1 Adjacent pairs
*3-1 CCF 2014-09-1 Adjacent pairs
2022-08-09 14:51:00 【Ye Xiaobai】
题目描述

源代码
#include<iostream>
using namespace std;
int a[1005];
int main()
{
int n;
cin >> n;
for (int i = 0; i < n; i++)
{
scanf("%d", &a[i]);
}
int i, j;
int count = 0;
for (i = 0; i < n; i++)
{
for (j = i + 1; j < n; j++)
{
if (abs(a[i] - a[j]) == 1)
{
count++;
}
}
}
cout << count << endl;
return 0;
}
关于这题
Using violence here The number of comparing two poor If the absolute value of1 符合条件 count++;
边栏推荐
- *4-1 CCF 2014-12-1 Access Control System
- 使用Connection对象连接管理事务
- 12. cuBLAS Development Guide Chinese version--Level-1 functions asum() and axpy() in cuBLAS
- 小程序程序开发怎么做?应以突出功能为主
- C语言中的 递归问题 以及将递归改写成非递归。(解析常见的几个递归题目及代码) 求阶乘、求斐波那契、汉诺塔、
- Three kinds of ThreadLocal, play with thread variable storage and transmission
- Recursive implementation of the Tower of Hanoi problem
- The code implementation of chess
- Simulate the realization of strcpy function (including multiple optimization ideas)
- *5-2 CCF 2014-12-3 集合竞价
猜你喜欢
随机推荐
flink并行度知识点
青蛙跳台阶
iptables防火墙
apt-cache 命令
What are the steps website small program development?
小程序程序开发怎么做?应以突出功能为主
小程序开发制作成本是多少?三种开发方法成本分析!
C语言 函数问题
Kubernetes资源编排系列之三: Kustomize篇
RHCE Course Summary
Dry+Bean+Dataset R language data analysis, report in English
*1-5 OJ 642 俄式乘法
RHCE Course Summary
预约直播 I 阿里云EMR StarRocks 产品发布会
小程序制作软件哪个好用?如何选择?
猴蝎美人
阿里巴巴开源大规模稀疏模型训练/预测引擎DeepRec
[Video coding learning] - SAD and SATD
Add-apt-repository command details
Minesweeper game









