A and B and Compilation Errors——找出消失的数字

本文介绍了一种通过排序和比较来确定被修正的编译错误的方法。这种方法适用于编程竞赛中快速定位并解决编译问题。
B. A and B and Compilation Errors
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

A and B are preparing themselves for programming contests.

B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code.

Initially, the compiler displayed n compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix some mistake and then another one mistake.

However, despite the fact that B is sure that he corrected the two errors, he can not understand exactly what compilation errors disappeared — the compiler of the language which B uses shows errors in the new order every time! B is sure that unlike many other programming languages, compilation errors for his programming language do not depend on each other, that is, if you correct one error, the set of other error does not change.

Can you help B find out exactly what two errors he corrected?

Input

The first line of the input contains integer n (3 ≤ n ≤ 105) — the initial number of compilation errors.

The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the errors the compiler displayed for the first time.

The third line contains n - 1 space-separated integers b1, b2, ..., bn - 1 — the errors displayed at the second compilation. It is guaranteed that the sequence in the third line contains all numbers of the second string except for exactly one.

The fourth line contains n - 2 space-separated integers с1, с2, ..., сn - 2 — the errors displayed at the third compilation. It is guaranteed that the sequence in the fourth line contains all numbers of the third line except for exactly one.

Output

Print two numbers on a single line: the numbers of the compilation errors that disappeared after B made the first and the second correction, respectively.

Sample test(s)
input
5
1 5 8 123 7
123 7 5 1
5 1 7
output
8
123
input
6
1 4 3 3 5 7
3 7 5 4 3
4 3 7 5
output
1
3
Note

In the first test sample B first corrects the error number 8, then the error number 123.

In the second test sample B first corrects the error number 1, then the error number 3. Note that if there are multiple errors with the same number, B can correct only one of them in one step.

大水题,只恨自己当初读懂了题意没有去做。。。。。。

第一行给出数字的个数,第二行给出原始数字,第三行给出处理一个数字之后剩下的数字,第四行给出处理两个数字之后剩下的数字,找出这两次分别处理的数字。

其实题目很简单,将给出的三行数据分别从小到大排序,因为有先后顺序,那么当找到一个不在原来序列中的数据时,就肯定是这个数据。具体看代码:

#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>

using namespace std;

__int64 sz1[100009],sz2[100009];

int main()
{
    int n,i,j,k;
    while(~scanf("%d",&n))
    {
        for(i = 0; i < n; i++)//输入第一行数据
        {
            scanf("%I64d",&sz1[i]);
        }
        for(i = 0; i < n-1; i++)//输入第二行数据
        {
            scanf("%I64d",&sz2[i]);
        }
        sort(sz1,sz1+n);//对这两组数据分别排序
        sort(sz2,sz2+n-1);
        k = 0;
        for(i = 0,j = 0; i < n; i++,j++)//从头到尾依次遍历
        {
            if(sz1[j] != sz2[i])//当发现两数据不相同时那么数据个数多的序列所在的那个数据肯定是被删除了
            {
                k = sz1[j];//这样就是找到了第一次修改的数据,直接输出即可
                break;
            }
        }
        printf("%d\n",k);
        memset(sz1,0,sizeof(sz1));
        for(i = 0; i < n-2; i++)
        {
            scanf("%I64d",&sz1[i]);
        }
        sort(sz1,sz1+n-2);
        for(i = 0,j = 0; j < n-1; j++,i++)
        {
            if(sz1[i] != sz2[j])
            {
                k = sz2[j];
                break;
            }
        }
        printf("%d\n",k);
    }
    return 0;
}


If you want to compile from the source, you need to have a C compiler, GNU make and zlib development files installed. Then type `make` in the source code directory to compile. If you see compilation errors, try `make sse2only=1` to disable SSE4 code, which will make minimap2 slightly slower. ./minimap2-2.30_x64-linux/minimap2 Usage: minimap2 [options] <target.fa>|<target.idx> [query.fa] [...] Options: Indexing: -H use homopolymer-compressed k-mer (preferrable for PacBio) -k INT k-mer size (no larger than 28) [15] -w INT minimizer window size [10] -I NUM split index for every ~NUM input bases [8G] -d FILE dump index to FILE [] Mapping: -f FLOAT filter out top FLOAT fraction of repetitive minimizers [0.0002] -g NUM stop chain enlongation if there are no minimizers in INT-bp [5000] -G NUM max intron length (effective with -xsplice; changing -r) [200k] -F NUM max fragment length (effective with -xsr or in the fragment mode) [800] -r NUM[,NUM] chaining/alignment bandwidth and long-join bandwidth [500,20000] -n INT minimal number of minimizers on a chain [3] -m INT minimal chaining score (matching bases minus log gap penalty) [40] -X skip self and dual mappings (for the all-vs-all mode) -p FLOAT min secondary-to-primary score ratio [0.8] -N INT retain at most INT secondary alignments [5] Alignment: -A INT matching score [2] -B INT mismatch penalty (larger value for lower divergence) [4] -O INT[,INT] gap open penalty [4,24] -E INT[,INT] gap extension penalty; a k-long gap costs min{O1+k*E1,O2+k*E2} [2,1] -z INT[,INT] Z-drop score and inversion Z-drop score [400,200] -s INT minimal peak DP alignment score [80] -u CHAR how to find GT-AG. f:transcript strand, b:both strands, n:don't match GT-AG [n] -J INT splice mode. 0: original minimap2 model; 1: miniprot model [1] -j FILE junctions in BED12 to extend *short* RNA-seq alignment [] Input/Output: -a output in the SAM format (PAF by default) -o FILE output alignments to FILE [stdout] -L write CIGAR with >65535 ops at the CG tag -R STR SAM read group line in a format like '@RG\tID:foo\tSM:bar' [] -c output CIGAR in PAF --cs[=STR] output the cs tag; STR is 'short' (if absent) or 'long' [none] --ds output the ds tag, which is an extension to cs --MD output the MD tag --eqx write =/X CIGAR operators -Y use soft clipping for supplementary alignments -y copy FASTA/Q comments to output SAM -t INT number of threads [3] -K NUM minibatch size for mapping [500M] --version show version number Preset: -x STR preset (always applied before other options; see minimap2.1 for details) [] - lr:hq - accurate long reads (error rate <1%) against a reference genome - splice/splice:hq - spliced alignment for long reads/accurate long reads - splice:sr - spliced alignment for short RNA-seq reads - asm5/asm10/asm20 - asm-to-ref mapping, for ~0.1/1/5% sequence divergence - sr - short reads against a reference - map-pb/map-hifi/map-ont/map-iclr - CLR/HiFi/Nanopore/ICLR vs reference mapping - ava-pb/ava-ont - PacBio CLR/Nanopore read overlap See `man ./minimap2.1' for detailed description of these and other advanced command-line options. (base) user@user:/data3$ make make: *** 没有指明目标并且找不到 makefile。 停止。
最新发布
10-19
<think>嗯,用户问的是“function created with compilation errors”,也就是在编译过程中出现错误的函数。首先,我需要理解这个问题的常见原因。可能用户是在编程的时候遇到了编译错误,特别是在定义函数的时候。那么,编译错误通常有哪些原因呢? 首先想到的是语法错误,比如缺少括号、分号或者拼写错误。比如在C语言里,函数声明如果漏了花括号或者分号,编译器就会报错。然后是类型不匹配,比如函数声明的返回类型和实际返回的值类型不一致,或者参数类型不匹配。例如,声明了一个返回int的函数,但实际返回了字符串。 还有作用域的问题,比如在函数内部使用了未声明的变量,或者变量名拼写错误。此外,函数重名也可能导致冲突,尤其是在大型项目中,如果函数名重复,编译器无法确定该用哪个,就会报错。 另外,有些语言需要函数在使用前声明,如果函数调用在定义之前,而编译器没有看到原型声明,也会出错。比如C语言中,如果函数定义在调用之后,而没有前置声明,就会报编译错误。 还有链接错误,比如函数声明了但没有实现,或者实现的时候参数列表不一致,导致链接器找不到对应的函数定义,这可能在编译阶段或链接阶段报错,具体看语言和编译器。 用户可能需要具体的例子来理解这些错误。比如举一个缺少分号的例子,或者参数类型不匹配的情况。同时,解决方法是检查语法,仔细核对函数声明和定义的每个部分,使用编译器的报错信息定位问题所在的行和具体原因。 另外,可能用户对编译错误的信息不太熟悉,不知道如何根据错误信息排查问题。这时候需要解释如何阅读错误信息,比如错误类型、行号、提示信息等,这些都是解决问题的关键线索。 总结下来,回答的结构应该先解释编译错误的原因,然后分点列出常见错误类型,给出例子,最后提供解决方法和建议。确保用户能够一步步排查问题,理解错误来源,并学会如何避免和修复。</think>在编程中,“function created with compilation errors”表示在编译阶段因代码错误导致函数无法正常通过编译。以下是逐步分析及常见原因: --- ### 一、什么是编译错误? 编译错误(Compilation Errors)是编译器在解析代码时发现的语法或语义问题。当函数存在此类错误时,编译器会拒绝生成可执行文件。 --- ### 二、常见错误类型及示例 #### 1. **语法错误** - **缺失符号**:如缺少分号 `;`、括号 `()` 或花括号 `{}`。 ```c int add(int a, int b) { return a + b // 错误:缺少分号 } ``` - **拼写错误**:如关键字拼写错误(`funciton` 代替 `function`)。 #### 2. **类型不匹配** - **返回值类型不符**: ```c int divide(int a, int b) { return a / b; // 正确 } float divide(int a, int b) { // 错误:与已存在函数冲突 return (float)a / b; } ``` - **参数类型错误**: ```java void print(String message) { ... } print(123); // 错误:参数应为字符串 ``` #### 3. **作用域问题** - **未声明变量**: ```python def calculate(): result = x + 5 # 错误:x 未定义 ``` #### 4. **重复定义** - **同名函数冲突**: ```c++ void log() { ... } void log() { ... } // 错误:函数重复定义 ``` #### 5. **未实现声明** - **声明未定义**: ```c void myFunction(); // 函数声明 int main() { myFunction(); // 错误:未实现具体定义 } ``` --- ### 三、解决方法 1. **阅读错误信息** 编译器会提示错误类型和位置(如行号)。例如: ``` error: expected ';' before '}' token ``` 2. **逐行检查代码** 检查符号闭合、拼写和语法结构。 3. **隔离测试** 注释掉部分代码,逐步定位问题。 4. **工具辅助** 使用 IDE 的语法高亮和实时检查功能(如 VS Code、IntelliJ)。 --- ### 四、示例修复 **错误代码**: ```c #include <stdio.h> int main() { printf("Hello World") return 0; } ``` **错误分析**:`printf` 后缺少分号 `;`。 **修复后**: ```c #include <stdio.h> int main() { printf("Hello World"); // 添加分号 return 0; } ``` --- ### 五、总结 编译错误通常由语法、类型或作用域问题引起。通过仔细阅读错误信息、检查代码逻辑,并结合工具辅助,可高效定位并解决问题。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值