2169 - I2P(I)2020_Huang_lab7 Scoreboard

Time

2020/11/12 08:00:00 2020/11/12 12:00:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
12985 Counting Inversions
12986 Poker Straight

12985 - Counting Inversions   

Description

Write a function to take two input parameters: an integer array a[] and its size n.  The function should return the number of inversions in a[0..n-1].  The number of inversions in an array a[0..n-1] is the number of index pairs (i,j) such that i<j but a[i]>a[j].

 

Write a driver program to get an input array and then pass it to your function. Again, try to organize your program into functions. You may assume that the array size is no more than 20.

E.g.

int inversion(...){

...

return ....

}

 

main () {

...

inversion(...);

...

}

Input

Integer array's size n, followed by its values

Output

The number of inversions in a[0..n-1]

Sample Input  Download

Sample Output  Download

Tags




Discuss




12986 - Poker Straight   

Description

Poker Straight

 

Straight

 

 

 

A Straight is one of the good poker hands that can be very valuable. It is made out of five cards of sequential ranking. The suits of the cards are not important when making a standard Straight.

What does a Straight look like?

A♥, K♦, Q♠, J♦, 10♣

Q♦, J♣, 10♥, 9♥, 8♠

7♥, 6♣, 5♥, 4♦, 3♣

 

Write a program to input five integers in the range [1,13] and determine if they are consecutive.  Hint: Define an array of size 13 to count the frequency of each value in [1,13].

Input

n n n n n

such that, 1 < n ≤ 13.

Output

"a straight\n" or "not a straight\n"

Sample Input  Download

Sample Output  Download

Tags




Discuss