当前位置:网站首页>(good pairs) assign the value of one array to another array
(good pairs) assign the value of one array to another array
2022-07-21 20:29:00 【This wa is good night】
Title Description
Give you an array of integers nums.
If a set of numbers (i, j) Satisfy nums[i] == nums[j] And i < j, It can be considered as a group of good pairs .
Please calculate the number of such good pairs .
Input
The input contains only one set of data ;
The first line contains only a positive integer n, Represents this array nums Its size is n (1 ≤ n ≤ 1000);
The second line contains n It's an integer nums[i] (1 ≤ nums[i] ≤ 1000).
Output
Output the number of pairs .
The sample input
6 1 2 3 1 1 3
Sample output
4
Tips
For example, enter , There are four groups of good pairs , Namely a1 == a4,a1 == a5,a3 == a6,a4 == a5 .
#include <stdio.h>
int main()
{
int n,a[1000],b[1000];
scanf("%d",&n);
for(int i=0;i<n;i++){
scanf("%d",&a[i]);
}
for(int i=0;i<n;i++){
b[i]=a[i];
}
int count=0;
for(int i=0;i<n;i++)
for(int j=i+1;j<n;j++){
if(a[i]==b[j])
count++;
}
printf("%d",count);
}
边栏推荐
- Pytorch installation
- Detailed explanation of scanf - scanf usage you don't know
- 小游戏类项目 —— 扫雷
- 吴恩达深度学习L4W4人脸识别
- 1009说反话
- (笔记)吴恩达深度学习L4卷积神经网络W1
- Bert from introduction to practice notebook
- Printf explanation - what you don't know about the usage of printf
- [PCB] production document sorting and output of circuit board drawing notes -- drawing board notes
- 22.【【静态成员访问格式】类名::访问成员,则该成员需要是静态】
猜你喜欢
如何使用正态分布变换进行配准
Semantic segmentation, instance segmentation
做题引发对getchar()的理解
Pre training and fine tuning of Google Bert model for beginners
Owncloud 9.0 better cross server sharing and scalability
无法从“boost::shared_ptr<pcl::RangeImage>”转换为“const std::shared_ptr<const pcl::PointCloud<pcl::PointWit
初学谷歌bert模型的预训练和fine-tuning微调
Those pits in distributed transactions
PCL运行时ucrtbased.dll引发的异常
矩阵求导常用公式(避坑)+矩阵的模和矩阵的绝对值的求导
随机推荐
4. 10 lines of code MNIST handwritten numeral recognition of paddlepaddle
吴恩达深度学习L4W3目标检测
matlab2021a配置gpu遇到错误error C1083: 无法打开包括文件: “gpu/mxGPUArray.h”: No such file or directory
深度剖析数据在内存中的存储
MySQL installation failed
1-10000水仙花数
Owncloud 9.0 better cross server sharing and scalability
Mmdetection environment matching (cuda10.1+mmdet2.24)
三子棋
22.【【静态成员访问格式】类名::访问成员,则该成员需要是静态】
Let the code solve the "linear algebra" series - polynomial summation
Account class
3. Build the basic model of paddlepaddle from scratch (compare with keras and pytorch)
1019 digital black hole
Examples of enumeration
模拟实现字符串函数和内存函数(strlen,strcpy,strstr,memcpy.....)
Stm32f407 based camera (ov7670 without FIFO) image acquisition and LCD display experiment - note sorting
Hetai 32 onenet WiFi module - Hetai MCU data cloud through mqtt protocol (I)
Yum install GCC error
Hetai ht32 -- taojingchi tjc--t0 serial port screen learning notes (II)