<>2021 The 12th Blue Bridge Cup C/C++B Group simulation

Problem description ：

Given a sequence a_1,a_2,…,a_n, among a_1 < a_2 < …< a_n.
The difference between two adjacent numbers （ Subtract the previous number from the latter number ） It's called their gap .
What is the largest gap in the sequence ?

Input format ：

The first line of input contains an integer n, Represents the length of the sequence .
The second line contains n A positive integer , For a given sequence .

Output format ：

Output an integer , Represents the largest gap in the sequence .
#include <stdio.h> int main() { int n; int i; int num[1000]; int count[999];
// Put the gap into the array for comparison int temp; // Intermediate variable scanf_s("%d", &n); for (i = 0; i < n; i++) {
scanf_s("%d", &num[i]); } for (i = 0; i < n; i++) // Calculate the clearance , And put it in count Array { count[i]
= num[i + 1] - num[i]; } for (i = 0; i < n - 1; i++) // Find the biggest gap { if (count[0] <
count[i]) { temp = count[0]; count[0] = count[i]; count[i] = temp; } } printf(
"%d", count[0]); return 0; }

Technology
Daily Recommendation