问题描述
这是一个C编程问题。
如果两个序列a和b具有相同数量的元素并且它们都包含少于两个,则它们是等价的数字或如果对于所有i,j,1≤i,j≤n,a [i]≤a[j]如果且仅当b [i]≤b[j],其中n是序列的长度。
顺序等价序列的例子:< 7,5,9,13,12>和< 4,2,25,33,26> < 12为氢;并且< 8>
在第一种情况下,序列的等级顺序< 7,5,9,13,12>是< 4th,5th,3rd,1st,2nd>。序列的等级顺序< 4,2,25,33,26>也是< 4th,5th,3rd,1st,2nd>。因此它们是相同的订单。
您的任务:创建一个C程序,测试两个数字序列是否等效。
程序必须接受两个序列,两者之间没有分隔符。如果接受的数字是n,则假设前n / 2个数字在第一个序列中,其余数字形成第二个序列。然后程序必须检查订单等效性并且必须将结果打印到控制台。 (如果收到奇数个数字,则声明两个序列不等同。)
程序的25分将是正确的(包括正确性) I / O),其他4点将用于样式和文档,以及我没有想到的任何其他软功能。
提交 .c和.h这个程序到家庭作业1保护箱的文件与这个家庭作业中其他问题的答案分开。
我尝试了什么:
我澄清了数组大小而没有从用户那里得到它。我也找到了两个数组中最大和最小的数字,但排名使我的问题更难。
This is a C programming problem.
Two sequences a and b are order equivalent if they have the same number of elements and if they both contain less than two numbers or if for all i, j, 1 ≤ i, j ≤ n, a[i] ≤ a[j] if and only
if b[i] ≤ b[j], where n is the length of a sequence.
Another way to say this is that two sequences are order equivalent if, when you replace the numbers in the sequences by their rank orders, the sequences of rank orders are identical.
Examples of order equivalent sequences: <7, 5, 9, 13, 12> and <4, 2, 25, 33, 26> <12> and <8>
In the first, case, the rank order of the sequence <7, 5, 9, 13, 12> is <4th, 5th, 3rd, 1st, 2nd>. The rank order of sequence <4, 2, 25, 33, 26> is also <4th, 5th, 3rd, 1st, 2nd>. So they are order equivalent.
Your task: Create a C program that tests whether two sequences of numbers are order equivalent.
The program must accept the two sequences with no separator between the two. If the number
of numbers accepted is n, the first n/2 numbers are assumed to be in the first sequence and
the rest form the second sequence. The program must then check for order equivalence and
must print the result to the console. (If an odd number of numbers are received, declare that the two sequences are not order equivalent.)
25 points of the program will be for correctness (including correctness of I/O), the other 4 points will be for style and documentation, and any other "soft" features that I haven't thought of.
Submit the ".c" and ".h" file(s) for this program to the Homework 1 dropbox separately from the answers to the other problems on this homework.
What I have tried:
I clarified the array size without getting it from user. I also found the biggest and smallest number of two arrays, but ranking made the problem harder for me.
推荐答案
这篇关于比较c中数组元素的等级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!