【问题标题】:Checker the output sequence is correct or not检查输出顺序是否正确
【发布时间】:2014-05-08 09:03:44
【问题描述】:

我正在做作业,必须检查结果,但问题是我不知道我需要填写什么。 检查器是什么意思?如果 input.txt ( inFile) 是 I 23 I 1 R 3 R 4 而 output.txt ( outFile) 是 23 0 0 0

#include<cstdio>

//Check whether the output sequence is correct or not.
//If it is correct, return true. Otherwise, return false.
bool Checker(FILE* inFile, FILE* outFile)
{
    //TODO
    return false;
}

int main(int argc, char* argv[])
{
    FILE* inFile = fopen(argv[1], "r"); 
    FILE* outFile = fopen(argv[2], "r");

    printf("%s\n", Checker(inFile, outFile)?"YES":"NO");

    fclose(outFile);
    fclose(inFile);
    return 0;
}

【问题讨论】:

  • 这里只有 cstdio 的 C++,不确定 C++ 标签是否合理。
  • 首先,您必须了解输入序列的预期输出序列是什么。您是否要检查输入和输出文件是否相同?

标签: c++ c file io


【解决方案1】:

将两个文件读入内存,并比较内存。

阅读例如mallocfseekftellrewindfreadmemcmp

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-03-10
    • 2021-11-25
    • 1970-01-01
    • 2017-07-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多