CCF Certification Exam September 2014 The first question describes a given n different integers, asking how many of these numbers are integers, and their values are exactly 1. Input format the first line of input contains an integer n, representing the number of given integers.
The second line contains the n integers given. Output format outputs an integer that represents the number of pairs that have a value that is exactly 1 apart. Sample Input 6
10 2 6 3 7 8 Sample Output 3 example shows that the number of pairs with a value of exactly 1 is (2, 3), (6, 7), (7, 8). Evaluation use case size and convention 1<=n<=1000, the given integer is a non-negative integer that does not exceed 10000.
#include <iostream>
using namespace Std;
int n,array[10000];
void Chuli (int a[10000])
{
int count=0;
for (int i=0;i<n;i++)
{
for (int j=i+1;j<n;j++)
{
if (a[i]==a[j]+1| | A[I]==A[J]-1)
{
Count+=1;
}
}
}
cout<<count<<endl;
}
int main ()
{
cin>>n;
for (int i=0;i<n;i++)
{
cin>>array[i];
}
Chuli (array);
return 0;
}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Given n different integers, ask how many of these numbers are integers, and their values are exactly 1 (CCF real problem)